Stop page refreshing when using buttons?

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
Hello there,

I'm using this javascript to make a button that opens a small, separate window to display images. It works perfectly for the new window, but whenever I hit the button the main page refreshes AND moves back up to the top of the page.

Is there any way to stop the main page refreshing?

Here's the script I'm using.

<SCRIPT language=JavaScript>

var width,height
var image,ext
var cond1,cond2
function transferview(image,width,height) {
if (width==0) cond1=" "
else cond1="width="+(width+20)+"";
if (height==0) {cond2=" "};
else {cond2="height="+(height+70)+""};

var s1 ="<TITLE>Image</TITLE>"
var s15=""
var s2 ="<CENTER><IMG SRC='"+image+"' BORDER=0>"
var s3 ="<FORM><INPUT TYPE='BUTTON' VALUE='Close Window'"+ " onClick='self.close()'>"
var s4 ="</FORM></CENTER>"

ImageWindow=window.open("", "newwin"+width,"toolbar=no,scrollbars="+scroll+",menubar=no,"+cond1+","+cond2);
ImageWindow.document.write(s1+s15+s2+s3+s4)
ImageWindow.document.close()
}
</SCRIPT>

<FORM><INPUT onclick="javascript:transferview('test.gif',200,300)" type=button value="View Image"> </FORM>



edit: I tried using the much simpler

<SCRIPT type="text/javascript" >
window.open('opened.html', 'joe', config='height=300,width=300')

</SCRIPT>

and it works fine as a pop up window (I hate pop ups) but when I try to add the commands to make it an onclick window it just opens as normal size despite my config bit.

There must be an easier way to do this... :confused:
 
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

Staff online

Top