onload event for new page?

41 views
Skip to first unread message

David Ethell

unread,
Dec 6, 2007, 4:44:16 PM12/6/07
to iPhoneWebDev
I've searched past discussions and can't find it. Is there a way to
specify some javascript to run on the loading of a new page?

I used on persons suggestion of searching for child nodes of type
script and doing eval on them, but I'd also like to have a simple
onload in the top element of the new page loaded by AJAX. Something
like:

<code>
<ul id="newpage" class="panel" onload="someFunction();">
<li>content</li>
</ul>
</code>

Any thoughts?

David

David Ethell

unread,
Dec 6, 2007, 8:31:03 PM12/6/07
to iPhoneWebDev
Here's how I implemented this for now...

I modified iui.js to look for an onload attribute after sliding:

<code>
percent = 0;
if (!hasClass(toPage, "dialog"))
fromPage.removeAttribute("selected");
clearInterval(timer);
checkTimer = setInterval(checkOrientAndLocation, 300);
setTimeout(updatePage, 0, toPage, fromPage);
if ( toPage.getAttribute("onload") ) {
eval(toPage.getAttribute("onload"));
}
</code>

Now I can simply put an onload attribute in my page tag per the
previous example. Haven't tested this thoroughly, but it got me past
my current hurdle.

David
Reply all
Reply to author
Forward
0 new messages