Google Custom Search Engines use a timer to check the hash against a previous value whilst the child iframe on a seperate Domain updates the parent's location hash to contain the size of the IFRAME document ' s body. When the timer catches the change, the parent can resize the IFRAME to match that of the body so, scrollbars aren ' t di Splayed.
Something like the following achieves the same:
var Storedhash = Window.location.hash;window.setinterval (function () {if (Window.location.hash! = Storedhash) { Storedhash = Window.location.hash; Hashchanged (Storedhash); }}, 100); Google uses 100ms intervals I think, might be lower
Google Chrome 5, Safari 5, Opera 10.60, Firefox 3.6 and Internet Explorer 8 all support the hashchange
event:
if ("Onhashchange" in window)//Does the browser support the Hashchange event? Window.onhashchange = function () {hashchanged (Window.location.hash); }
and putting it together:
if ("Onhashchange" in window) { // event supported? window.onhashchange = function () { hashchanged (Window.location.hash); }} else { // event not supported: var storedhash = window.location.hash; window.setinterval (function () { if (Window.location.hash != storedhash) { storedHash = window.location.hash; hashchanged (StoredHash); } }, 100);}
JQuery also have a plugin that would check for the Hashchange event and provide its own if necessary-http://benalman.com/p rojects/jquery-hashchange-plugin/.