I don't use the #named anchor links. They always cause the URL bar to
appear/disappear. If I want to jump down to a section, I make a call to the
following script and it jumps down instantly, without invoking the address
bar. I use this for the vertical alphabet links on the right to jump to a
letter header in my listings. I'm sure it could be adapted so you can
create a url like "http://company.com/file.html?anchor=xyz" and then run
this script after the (0,1) scroll script to hide the address bar.
function divscrollTo(container, element)
{
container = $(container);
element = $(element);
var y = element.y ? element.y : element.offsetTop;
container.scrollTop=y-(document.all?0:container.offsetTop);
return element
}
-=Randy
On 8/24/07 11:27 AM, "Christopher Allen" <[EMAIL PROTECTED]>
wrote:
>
> 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
-~----------~----~----~----~------~----~------~--~---