Most people on this list are using the iPhone script that hides the
URL bar based on this example:
<script type="application/x-javascript">
addEventListener("load", function()
{
setTimeout(hideURLbar, 0);
}, false);
function hideURLbar()
{
window.scrollTo(0, 1);
}
</script>
However, the problem with this technique is that URLs that have name
references ( i.e. http://company.com/file.html#name ) which should
change the window.scrollTo to the <a name="name" /> tag, will fail to
work. This is because the window will be scrolled to the name before
the page is fully loaded, and then the hideURLbar will be called that
will return the page to 0,1.
I've changed the example script for this for now so that this function
is only called when running on the iPhone:
<script type="application/x-javascript">
if (navigator.userAgent.indexOf('iPhone') != -1)
{
addEventListener("load", function()
{
setTimeout(hideURLbar, 0);
}, false);
}
function hideURLbar()
{
window.scrollTo(0, 1);
}
</script>
A better solution might be to look at the URL being loaded and if it
contains a #name reference, it should not hide the URL bar. Or maybe
there is some way to hide the URL bar and then move to the reference
anchor.
I'd like to update the iPhoneWebDev examples page on this topic, so if
anyone wants to write a better script, I would welcome it.
-- Christopher Allen
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---