There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer cpu crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware missing monitor network networking outlook outlook 2003 outlook 2007 outlook express password popups problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Stop page refreshing when using buttons?


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Shelob's Avatar
Computer Specs
Senior Member with 146 posts.
 
Join Date: Aug 2002
Location: Portugal
Experience: Impatient intermediate beginner.
02-Jul-2005, 03:06 PM #1
New windows, refreshes and buttons, oh my.
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+","+con d2);
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...

Last edited by Shelob : 02-Jul-2005 04:56 PM.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:20 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.