Click to See Complete Forum and Search --> : weird behavior w/ window.open()


Sotorin
03-24-2003, 01:29 PM
Can someone explain the difference between the two and why the link version doesn't work and after I click on it [object] appears on the page and I have to "go back" to see the calling page.
The button works as intended. Here is copy of the HTML
-------
<html>
<head>
<title>Untitled Document</title>

</head>

<body>
<a href="javascript:window.open('http://www.yahoo.com');">test</a><br>
<input type=button value="Open Window" onClick="javascript:window.open('http://www.yahoo.com');">
</body>
</html>
----------------------

AdamBrill
03-24-2003, 01:37 PM
Try this instead:<html>
<head>
<title>Untitled Document</title>

</head>

<body>
<a href="#" onclick="javascript:window.open('http://www.yahoo.com'); return false;">test</a><br>
<input type=button value="Open Window" onClick="javascript:window.open('http://www.yahoo.com');">
</body>
</html>

nkaisare
03-24-2003, 02:02 PM
You may want to use
<a href="http://www.yahoo.com" onclick="javascript: open('http://www.yahoo.com'); return false;">Yahoo!</a>

This way, your visitors will go to Yahoo page irrespective of whether they have javascript or not (eg some people turn off javascripts while browsing).

Personal opinion: I hate when a new browser window is opened. If I want to open a new window, I'll do that myself. I prefer using [Backspace] than using [alt-F4] to return to the parent page. :)

nkaisare
03-24-2003, 02:03 PM
Of course there is no space in "java script"... the forum adds it (security reasons???).

Sotorin
03-24-2003, 02:50 PM
Suggestions were right on the money ... works like a charm!