473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Open new window with JS

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','','sc rollbars=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?

You can see this at http://www.pgacon.com/testpage.htm

--
Peter Aitken

Remove the crap from my email address before using.
Jul 23 '05 #1
7 2130
Lee
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','','s crollbars=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?


The HREF attribute tells the link what to display in the current
window. You're telling it to display the value returned by the
javascript method "window.open(...)". That value is a window
object, which displays as "[object]".

If you don't want to display the value of a Javascript expression,
don't use the "javascript:" protocol. If you don't want to change
the contents of the current window at all, have the onclick handler
of the link return false.

This also makes it possible for people to use the link if they
don't have Javascript enabled.

<a href="email_me.htm"
onclick="window.open('email_me.htm','validName','h eight=260,width=400);return
false"
onmouseover="changeImagesX('EmailMe_Layer_1','imag es/EmailMe_Layer-1-over.gif');
return true;"
onmouseout="changeImagesX('EmailMe_Layer_1','image s/EmailMe_Layer-1.gif');
return true;"><img
name="EmailMe_Layer_1"
src="images/EmailMe_Layer-1.gif"
border="0"
width="140"
height="25"></A>

Jul 23 '05 #2
"Lee" <RE**************@cox.net> wrote in message
news:cb*********@drn.newsguy.com...
Peter Aitken said:

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

<A
HREF="javascript:window.open('email_me.htm','','s crollbars=0,menubar=0,heig

h
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 thenew 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?


The HREF attribute tells the link what to display in the current
window. You're telling it to display the value returned by the
javascript method "window.open(...)". That value is a window
object, which displays as "[object]".

If you don't want to display the value of a Javascript expression,
don't use the "javascript:" protocol. If you don't want to change
the contents of the current window at all, have the onclick handler
of the link return false.

This also makes it possible for people to use the link if they
don't have Javascript enabled.

<a href="email_me.htm"

onclick="window.open('email_me.htm','validName','h eight=260,width=400);retur
n false"
onmouseover="changeImagesX('EmailMe_Layer_1','imag es/EmailMe_Layer-1-over.gi
f'); return true;"
onmouseout="changeImagesX('EmailMe_Layer_1','image s/EmailMe_Layer-1.gif'); return true;"><img
name="EmailMe_Layer_1"
src="images/EmailMe_Layer-1.gif"
border="0"
width="140"
height="25"></A>


Thanks for the info, Lee - it helped but it is still not right - the new
page opens in the original browser window instead of a new window. Here's
the code:

<a href="email_me.htm"
onclick="window.open('email_me.htm','validName','h eight=260,width=400);retur
n false;"
onmouseover="changeImagesX('EmailMe_Layer_1','imag es/EmailMe_Layer-1-over.gi
f');return true;"
onmouseout="changeImagesX('EmailMe_Layer_1','image s/EmailMe_Layer-1.gif');re
turn true;">
<img name="EmailMe_Layer_1"
src="images/EmailMe_Layer-1.gif"
border="0"
width="140"
height="25"></A>

The test page is still at www.pgacon.com/testpage.htm

Any other ideas? Thanks-

--
Peter Aitken

Remove the crap from my email address before using.
Jul 23 '05 #3
Peter Aitken wrote:
Lee wrote: <snip> <a href="email_me.htm"
onclick="window.open('email_me.htm','validName','h eight=260,width=400);
^ ^
Error: unterminated string constant.
return false;" <snip> Any other ideas?


Read (and understand) the error messages that the browser generates.

Richard.
Jul 23 '05 #4
Lee
Peter Aitken said:
Thanks for the info, Lee - it helped but it is still not right - the new
page opens in the original browser window instead of a new window. Here's
the code:

<a href="email_me.htm"
onclick="window.open('email_me.htm','validName',' height=260,width=400);retur
n false;"
onmouseover="changeImagesX('EmailMe_Layer_1','ima ges/EmailMe_Layer-1-over.gi
f');return true;"
onmouseout="changeImagesX('EmailMe_Layer_1','imag es/EmailMe_Layer-1.gif');re
turn true;">
<img name="EmailMe_Layer_1"
src="images/EmailMe_Layer-1.gif"
border="0"
width="140"
height="25"></A>


I made a typo that causes the window.open() call to fail, which
causes the "return false" to never be executed, allowing the
link to be followed, opening the page in the current window.

There should be a closing single-quote after the window attributes:

window.open('email_me.htm','validName','height=260 ,width=400');returen false

Jul 23 '05 #5
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:cb*******************@news.demon.co.uk...
Peter Aitken wrote:
Lee wrote:

<snip>
<a href="email_me.htm"

onclick="window.open('email_me.htm','validName','h eight=260,width=400);
^ ^
Error: unterminated string constant.
return false;"

<snip>
Any other ideas?


Read (and understand) the error messages that the browser generates.

Richard.


Ah, but it did not generate any error messages! In any event the problem is
fixed now.
--
Peter Aitken

Remove the crap from my email address before using.
Jul 23 '05 #6
"Lee" <RE**************@cox.net> wrote in message
news:cb********@drn.newsguy.com...
Peter Aitken said:
Thanks for the info, Lee - it helped but it is still not right - the new
page opens in the original browser window instead of a new window. Here's
the code:

<a href="email_me.htm"
onclick="window.open('email_me.htm','validName',' height=260,width=400);retu

r
n false;"


onmouseover="changeImagesX('EmailMe_Layer_1','ima ges/EmailMe_Layer-1-over.g

i
f');return true;"


onmouseout="changeImagesX('EmailMe_Layer_1','imag es/EmailMe_Layer-1.gif');r

e
turn true;">
<img name="EmailMe_Layer_1"
src="images/EmailMe_Layer-1.gif"
border="0"
width="140"
height="25"></A>


I made a typo that causes the window.open() call to fail, which
causes the "return false" to never be executed, allowing the
link to be followed, opening the page in the current window.

There should be a closing single-quote after the window attributes:

window.open('email_me.htm','validName','height=260 ,width=400');returen

false


Yikes, I should have caught that myself! Thanks a lot - it's been a big
help.
--
Peter Aitken

Remove the crap from my email address before using.
Jul 23 '05 #7
Peter Aitken wrote:


Ah, but it did not generate any error messages! In any event the problem is
fixed now.


Yes it did.
Mick
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Paul | last post by:
I link to a web site from an Excel spreadsheet. The page i link to is getCookie.asp which sets a cookie then returns back some html which opens a new window, to the same site but a different page...
6
by: Les | last post by:
Hi, I'd like to find out how to use the window.open() script in Fireworks MX. I have posted my question in the Fireworks forum but didn't get any replies. Since it's javascript, maybe someone...
10
by: Marshall Dudley | last post by:
When I do the following line in Netscape, the popup loads as it should, but the parent window usually, but not always, reloads as well. <a href="#"...
10
by: David McCulloch | last post by:
The following code opens a new window, but the "resizeTo" doesn't resize it. Why not? (Don't ask why I simply did not open the window with the new size....my original problem was how to open a...
2
by: Samir Pandey | last post by:
Hello, I am using the following javascript code to open a new window. Somehow, IE always opens a new window. It doesn't open target url in the window name given. All i want is, if there is a...
3
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The...
2
by: Larry R Harrison Jr | last post by:
I have pull-down menus in javascript and I have the code for opening a link in a new window. But I want it to open a full-sized window. I can't figure out the syntax. What I have so far: ...
8
by: Dominic Tocci | last post by:
I'm searching for a way to use window.open on my web page to open a window in firefox that allows the sidebars to work (bookmarks, history, etc). When I use the following: var...
7
by: anthony.turcotte | last post by:
Hi, I've looked for a solution to this problem on google, read posts in this newsgroup and I still haven't found anything that could help me. Here's the scenario. 1. User accesses...
13
by: Geoff Fox | last post by:
I am in the final moments of designing a new website. One of the pages (http://www.auditionfactory.com/samples.php) has four links to show sample work. I would like these links to open new...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.