---
title: "back button history handling for iframe with jquery (IE failed me again)"
author: "lerluc"
date: "2009-08-24T02:53:35Z"
tags: []
categories: ["Web前端"]
slug: "back-button-history-handling-for-iframe-with-jquery-ie-failed-me-again"
draft: false
lastmod: "2010-03-10T13:13:59Z"
id: 456072
url: "https://lerluc.iteye.com/blog/456072"
---

```html
<script src=js/jquery/1.3.2.js></script>
<script src=js/jquery/timers.js></script>
<a name=n1 url=http://g.cn />
<a name=n2 url=http://sohu.com />
<a name=n3 url=http://pcpop.com />
<a href=#n1>g.cn</a>
<a href=#n2>sohu.com</a>
<a href=#n3>pcpop.com</a>
<hr/>
<iframe name=iframe width=1280 height=1024></iframe>
<script>
var cm = {hash: ''}
$(document).everyTime(100, function(){
	var hash = location.hash
	if(hash && cm.hash != hash){
		cm.hash = hash
		frames.iframe.location.replace($('a[name='+hash.slice(1)+']').attr('url'))
	}
})
</script>

```


Doesn't work in IE...>_<

Turns out there are plugins for this already...[jQuery history](http://www.mikage.to/jquery/jquery_history.html) [jQuery Address](http://www.asual.com/jquery/address/) [jQuery BBQ](http://benalman.com/projects/jquery-bbq-plugin)