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

lerluc發表於2009-08-24
<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...[url=http://www.mikage.to/jquery/jquery_history.html]jQuery history[/url] [url=http://www.asual.com/jquery/address/]jQuery Address[/url] [url=http://benalman.com/projects/jquery-bbq-plugin]jQuery BBQ[/url]

相關文章