Page 1 of 1
maddening anchor refresh problem
Posted: Fri May 13, 2011 3:39 pm
by bobthebuilder
Hello, I am using an achor in a self referencing php script so that after the user clicks an image, the page is returned to a particular point in the page. This works great unless the same image is clicked twice, in which case the click (a $_GET) is totally ignored!
For example here is the link once the image is selected
Code: Select all
http://localhost/web/webplus_php/ws_board_design.php?sel_image_link=tb_sm_CIMG1207.gif&lib=hank#4509
so on clicking it the first time it works fine, but if I use it a second time nothing happens. However if I press F5, the process works fine. Also if I remove the anchor, so that the link is just
Code: Select all
http://localhost/web/webplus_php/ws_board_design.php?sel_image_link=tb_sm_CIMG1207.gif&lib=hank
I can click the image twice in a row no problem.
Does anyone have any clue as to why this should be happening?
Re: maddening anchor refresh problem
Posted: Fri May 13, 2011 10:34 pm
by califdon
What you need to show us is the link syntax itself. The entire <a .......> tag contents.
Re: maddening anchor refresh problem
Posted: Sat May 14, 2011 4:32 am
by bobthebuilder
Thanks for looking:
the url is
and the code that builds this reference is
$anchor_ref = "#mboard";
$action = $script . "?sel_image_link=" . $the_file->getFilename() . htmlentities("&") . "lib=" . $selected_lib . $anchor_ref;
echo '<a href="' . $action . '">';
echo '<img src="get_thumb2.php?image=' . $the_file->getFilename() . htmlentities("&") . "lib=" . $selected_lib . '" alt="" title="' . $can_text . '"' . "/></a>";
In general the code above all works, (i.e. processes the selected image and opens at the correct point in the page) but when the same image is selected on sucessive ocassions, the second processing operation is ignored, although we do still jump to the correct point in the page. Having put debug prints in, I believe the code that processes the users click, i.e.
if( isset($_GET['sel_image_link']))
is being ignored.
Furthermore if I set
$anchor_ref = "";
in the above (so nolonger using an anchor) successive links work fine! The anchor seems to be killing the _GET when the parameter is the same on both occasions.
Re: maddening anchor refresh problem
Posted: Sat May 14, 2011 10:24 am
by bobthebuilder
I'm getting in a right old pickle over this now. I currently think that when the #id is included, the script seems to be (partially at least) run twice, which causes havoc to my script.
Maybe an anchor does not work as I expect. Is it sensibleto do what I am doing? I have a script that generates a list of images, each one with an href back to the same page. When the link is clicked, the script is re-run and a master image file has a copy of the image that was selected added to it. That works fine, but I want the php file to jump to the master image file image, not load from the top, hence my use of anchors.