Jump to content

onclick goes to top of page


arbitter

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/232556-onclick-goes-to-top-of-page/
Share on other sites

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.

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 ::)

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.