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
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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.