anchor fails on 1st visit, works on 2nd+
Moderator: General Moderators
anchor fails on 1st visit, works on 2nd+
I'm new to php and have written a simple link as follows:
echo '<a href="'.$_SERVER['PHP_SELF'].'?album='.$dir.'&picture='.$nextImage.'#pin">Next</a>';
I have the anchor as <a name=pin></a> about halfway down the page.
When I follow the link the first time, the anchor is ignored. Every single call I make afterwards to the same link, the anchor works. This is obviously not much good for visitors to my site who may only view pictures once. The URL appears correctly in the browser with #pin on the end.
How on earth can I make it work on the first call? It's like the page needs to be cached before it will work. (viewing with IE6), has anyone else seen this and got round it?
echo '<a href="'.$_SERVER['PHP_SELF'].'?album='.$dir.'&picture='.$nextImage.'#pin">Next</a>';
I have the anchor as <a name=pin></a> about halfway down the page.
When I follow the link the first time, the anchor is ignored. Every single call I make afterwards to the same link, the anchor works. This is obviously not much good for visitors to my site who may only view pictures once. The URL appears correctly in the browser with #pin on the end.
How on earth can I make it work on the first call? It's like the page needs to be cached before it will work. (viewing with IE6), has anyone else seen this and got round it?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Hmm. I hadn't thought about the timing aspect.
You can see the problem at http://www.fayewilliams.com/gallery-mai ... 250062.jpg
Select 'next' and it will load the page from the top instead of jumping to the anchor point. If you then select 'previous' it does work, and then 'next' after that and its ok. You can only ever see the problem once on each picture and then you have delete all your cache to recreate it.
Same on IE and Firefox. It's driving me mad!
You can see the problem at http://www.fayewilliams.com/gallery-mai ... 250062.jpg
Select 'next' and it will load the page from the top instead of jumping to the anchor point. If you then select 'previous' it does work, and then 'next' after that and its ok. You can only ever see the problem once on each picture and then you have delete all your cache to recreate it.
Same on IE and Firefox. It's driving me mad!
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Hmm... doesn't look like a timing issue... the only thing that loads slow (although nothing unordinary) is the image.
I can't get it to work even the once using FF 1.05 on Linux.
<off topic>
I kinda got sucked into looking throguh the photography
I love that stuff.. I used to photograph trees too. Silhouetted on colorful skies - we're going back about 7 years now when I was doing GCSE (16 yo) exams... my final piece was two complimentary A1 chalk pastel works based on the photography I'd done throughout the year and partly influenced by Atkinson Grimshaw (Oil on canvas artist who loved his moonlight scenes - though not always with trees
).
</off topic>
Try this although it *shouldn't* make a difference:
EDIT | It's working now
I think it is a caching issue. I know there's a fix... I just can't think of it
- someone clever should pick up on that note and provide the fix 
I can't get it to work even the once using FF 1.05 on Linux.
<off topic>
I kinda got sucked into looking throguh the photography
</off topic>
Try this although it *shouldn't* make a difference:
Code: Select all
<!-- Not sure it's valid XHTML -->
<a name="e;pin"e; />
and this
<!-- Added quote marks -->
<a name="e;pin"e;></a>Your final submission for Art sounds cool
. I wish I had more time for working on things like that.
I tried your suggestions but no luck - it sort of 'feels' like it's something to do with the anchor being on the same page that's being reloaded, so I might restructure things a bit later on this evening.
If I find a solution I'll post it...
I tried your suggestions but no luck - it sort of 'feels' like it's something to do with the anchor being on the same page that's being reloaded, so I might restructure things a bit later on this evening.
If I find a solution I'll post it...
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I was about to say I've preloaded images with JavaScript but I hate relying on JS to do trivial things.
So...
http://www.netmechanic.com/news/vol6/css_no18.htm
CSS can preload the image in the previous page...
Not 100% how well it will work but it could be worth a shot
So...
http://www.netmechanic.com/news/vol6/css_no18.htm
CSS can preload the image in the previous page...
Not 100% how well it will work but it could be worth a shot
I don't really see the problem either. However, whenever someone clicks a next link, you could call a function onLoad() to go to that element
Something along the lines of
My javascript is barely existant, so that may not be the proper code.
d11wtq | It's not - but nice pseudo code
Something along the lines of
Code: Select all
<html>
<body onLoad="e;document.location.getElementById("e;pin"e;);"e;>d11wtq | It's not - but nice pseudo code
Ah ha! Your comments about pre-loading the images made me think about things in a different way, and I suddenly realised what was happening...
My style sheet doesn't specify the space the image will use, so it was going to the anchor on load up, but the page was too short to show it because the image hadn't arrived to fill the space. On subsequent visits, the image is cached, hence the page is physically longer and the anchor works.
I've modified the style to create an area that the picture will go in when it loads. It now works every time
.
Thanks guys, sometimes you just need a prod in the right direction.
My style sheet doesn't specify the space the image will use, so it was going to the anchor on load up, but the page was too short to show it because the image hadn't arrived to fill the space. On subsequent visits, the image is cached, hence the page is physically longer and the anchor works.
I've modified the style to create an area that the picture will go in when it loads. It now works every time
Thanks guys, sometimes you just need a prod in the right direction.