ITeye博客

back button history handling for iframe with jquery (IE failed me again)

lerluc · 2009-08-24 02:53 · Web前端 · Markdown

<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 jQuery Address jQuery BBQ

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。