Archive

Posts Tagged ‘javascript’

Safari window.onload timing issue

October 9th, 2009 aaron 9 comments

I ran into some Safari related timing issues at work, that I thought were worthy of a post.  To preface the post I’m using the dojo framework.  On to the post…

I needed to position a flash overlay relative to the absolute postion of a div that will vary in position on subsequent page loads.  So in comes the handy dojo.coords(id) function wrapped in a dojo.addOnLoad.  This works like a charm in firefox 3, ie 6, ie7 and google chrome.  In safari, no dice.  The offsetTop and offsetLeft calculations were completely off (I tried this with my own custom function as well as dojo.coords())  I was finally able to get this to work with using a setTimeout delay (hack).

After researching the issue it seems apple decided to make window.onload fire “before” the page loads.  (Seems counterintuitive to me, but it’s no wonder it’s so fast in benchmarks)  This explains the miscalculation of element positioning on the page.  Waiting for the page to load with a timeout fixes the problem.  The solution is a hack and is obviously not fool proof as in there is no real barrier to execution.  Does anyone in the interweb out there know how to get Safari to fire onload as in when the page actually finishes loading?  Knock knock.

New York City Subway Route Finder With Google Maps

December 11th, 2008 aaron No comments

Watch out Hopstop!  I wrote a Graph lib in python along with heuristic hSLD A* search and brought it to life with google maps and Ajax.  The library is running as a json-rpc service with mod_python.  The next step is to use geocoding api to turn street addresses to lat and lon coordinates and integrate it to find starting and ending stations, fun fun fun.

Maybe Ill put this on google app engine if I get alot of hits.

http://www.dancygier.com/nycsubway