Opening new window with javascript

P

Peter Aitken

I want to include a button that has rollover effects and also is a link to a
page that will open in a new window. Here's the code I am using:

<A
HREF="javascript:window.open('email_me.htm','','scrollbars=0,menubar=0,heigh
t=260,width=400,toolbar=0');"
ONMOUSEOVER="changeImagesX('EmailMe_Layer_1',
'images/EmailMe_Layer-1-over.gif'); return true;"
ONMOUSEOUT="changeImagesX('EmailMe_Layer_1', 'images/EmailMe_Layer-1.gif');
return true;">
<IMG NAME="EmailMe_Layer_1" SRC="images/EmailMe_Layer-1.gif" BORDER=0
width="140" height="25"></A>

Everything works OK - the rollovers work and when the button is clicked the
new window opens. The problem is that the original window goes blank and
displays only the text [object]. How can I do what I want and have the
original window retain its contents?
 
K

Kevin Spencer

Do you have a URL we can look at?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
P

Peter Aitken

Try http://www.pgacon.com/testpage.htm

Thanks

--
Peter Aitken

Remove the crap from my email address before using.

Kevin Spencer said:
Do you have a URL we can look at?

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Peter Aitken said:
I want to include a button that has rollover effects and also is a link
to
a
page that will open in a new window. Here's the code I am using:

<A
HREF="javascript:window.open('email_me.htm','','scrollbars=0,menubar=0,heigh
t=260,width=400,toolbar=0');"
ONMOUSEOVER="changeImagesX('EmailMe_Layer_1',
'images/EmailMe_Layer-1-over.gif'); return true;"
ONMOUSEOUT="changeImagesX('EmailMe_Layer_1', 'images/EmailMe_Layer-1.gif');
return true;">
<IMG NAME="EmailMe_Layer_1" SRC="images/EmailMe_Layer-1.gif" BORDER=0
width="140" height="25"></A>

Everything works OK - the rollovers work and when the button is clicked the
new window opens. The problem is that the original window goes blank and
displays only the text [object]. How can I do what I want and have the
original window retain its contents?
 
M

MD Websunlimited

Peter,

The problem is that when you use the window open function as the href it expects the href to refer to the next page; so what you get
is a page with [object] in it -- the JavaScript code. To correct, use an onclick event handler with the window open function and
returning a false value, e.g,

<a href="javascript:void(0);" onclick="window.open(....); return false;" >

--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
J-Bots Plus 2002 87 components for FrontPage
http://www.websunlimited.com/order/Product/JBP2002/jbp_help_dir.htm
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top