Solved: Stop the page refreshing?

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Shelob

Thread Starter
Joined
Aug 10, 2002
Messages
180
Dear knowledgeables,

I use a small simple script for an event button that opens a small window on demand, it works fine.
However, when I replace the button with an image for the same effect it works, but the main window refreshes (and goes back to the top of the page). Why is that? And most importantly, how do I stop it happening?

I would be very grateful for any advice (in simple terms, if possible :) ) thanks.

Here is the code I'm currently using for the button:

<FORM>
<INPUT type="button" value="Open image" onClick="window.open('http://www.mysite address/page.htm','BOB','width=400,height=600,left=250,top=100,screenX=250,screenY=100')">
</FORM>

And for using an image instead:

<FORM>
<INPUT TYPE="image" SRC="http://www.mysiteaddress/image.gif" HEIGHT="37" WIDTH="37" BORDER=0 ALT="picture button" onClick="window.open('http://www.mysite address/page.htm','BOB','width=400,height=200,left=250,top=100,screenX=250,screenY=100')">
</FORM>


(p.s. ten days ago I posted an older version of this question that is now surplus to requirement, if I could have deleted it I would, is that a thing for admin? Please forgive my ignorance.)
Shelob.
 
Joined
Jul 8, 2002
Messages
14,681
You shouldn't be using a <FORM> since there's no action set. You also were missing some quotes, and don't need to capitalize attributes.

Use this instead
<img src="http://www.mysiteaddress/image.gif" height="37" width="37" border="0" alt="picture button" onclick="javascript:window.open('http://www.mysite address/page.htm','BOB','width=400,height=200,left=250,top=100,screenX=250,screenY= 100')">
 

Shelob

Thread Starter
Joined
Aug 10, 2002
Messages
180
Thank you for replying,

(edit)
Brendandonhu, after initially thinking it didn't work and I'd somehow messed up your nice code, I discovered it did indeed work and WITHOUT refreshing the page! :) I was caught off guard because the cursor didn't change from an arrow to a hand when I moused over the image button, but it still worked anyway.

Thank you so much for your help! I'm absolutely delighted.
Shelob.
 

Shelob

Thread Starter
Joined
Aug 10, 2002
Messages
180
I can? Would it be very cheeky of me if I asked you how? ;)
 
Joined
Jul 8, 2002
Messages
14,681
Heh, should've added that :D. Just surround it by an <a href> tag.


<a href="javascript:void(0);"><img src="http://www.mysiteaddress/image.gif" height="37" width="37" border="0" alt="picture button" onclick="javascript:window.open('http://www.mysite address/page.htm','BOB','width=400,height=200,left=250,top=100,screenX=250,screenY= 100')"></a>
 

Shelob

Thread Starter
Joined
Aug 10, 2002
Messages
180
You're my hero. Thank you :)
Case most definitely solved!
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top