arbitter Posted April 3, 2011 Share Posted April 3, 2011 Hi there, I have a little problem. I have this big page with all small images, and when you click it it opens a new window with the image, but bigger. But then when you go back to the previous page, the page goes back to the top, i presume due to the href='#'. How can I fix this so that the original window doesn't go to the top? <a href='#' onclick=\"Popup=window.open('http://mydomain/picture.jpg','Picture')\"><img src='http://mydomain/picture.jpg' /></a> Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/ Share on other sites More sharing options...
cssfreakie Posted April 3, 2011 Share Posted April 3, 2011 well what you can try is, add the following above the part of the page you want to stop. <a name="activesection"></a> than set the link to this: <a href='#activesection' onclick=\"Popup=window.open('http://mydomain/picture.jpg','Picture')\"><img src='http://mydomain/picture.jpg' /></a> Anyway i never work with pop ups. But I am pretty sure you now know how to link to a certain position of a page. Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1196233 Share on other sites More sharing options...
arbitter Posted April 3, 2011 Author Share Posted April 3, 2011 I thought about that too, but I was hoping there would be a way without the browser changing the position it the page is... Is there no way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1196264 Share on other sites More sharing options...
cssfreakie Posted April 3, 2011 Share Posted April 3, 2011 I thought about that too, but I was hoping there would be a way without the browser changing the position it the page is... Is there no way of doing this? hmm i am not sure if there is. Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1196267 Share on other sites More sharing options...
arbitter Posted April 3, 2011 Author Share Posted April 3, 2011 Okay then, I'll use this then! It's just more complicated because of all the id's and names already flowing through my script, but I'm sure it'll be ok like this. Just more work than a simple added tag or so. Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1196334 Share on other sites More sharing options...
cssfreakie Posted April 3, 2011 Share Posted April 3, 2011 well I am not sure if it is possible but if you were able to get the coordinates of the page and set those in a variable inside of a back-button this might be done without id's, but i know nothing about that, just an idea Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1196336 Share on other sites More sharing options...
spiderwell Posted April 3, 2011 Share Posted April 3, 2011 mmm i haven't tested this but I am sure I used to get around this by adding a return false; on the end of the javascript after its called the popup. Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1196371 Share on other sites More sharing options...
spiderwell Posted April 3, 2011 Share Posted April 3, 2011 sorry i not sure if I perhaps read it right, when you says opens a new window you mean a pop up or just a page linking to the image? so my response my be completely useless lol. Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1196373 Share on other sites More sharing options...
dcro2 Posted April 9, 2011 Share Posted April 9, 2011 I'm pretty sure if you add "return false;" to your onclick the page won't move. Like this: <a href='#' onclick=\"Popup=window.open('http://mydomain/picture.jpg','Picture'); return false;\"><img src='http://mydomain/picture.jpg' /></a> Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1199097 Share on other sites More sharing options...
cssfreakie Posted April 9, 2011 Share Posted April 9, 2011 I'm pretty sure if you add "return false;" to your onclick the page won't move. Like this: <a href='#' onclick=\"Popup=window.open('http://mydomain/picture.jpg','Picture'); return false;\"><img src='http://mydomain/picture.jpg' /></a> Good one! here is some more info on that return false; thing http://cs110.wellesley.edu/examples/return.html Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1199099 Share on other sites More sharing options...
arbitter Posted April 9, 2011 Author Share Posted April 9, 2011 Allright thanks a bunch! This is very handy Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1199410 Share on other sites More sharing options...
spiderwell Posted April 11, 2011 Share Posted April 11, 2011 Ah so my hunch was right Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1199982 Share on other sites More sharing options...
dcro2 Posted April 12, 2011 Share Posted April 12, 2011 Ah so my hunch was right Woops, how did I skip over your post ? I didn't notice it until now.. must have been really tired when I posted haha. Quote Link to comment https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/#findComment-1200362 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.