Forum Moderators: open

Message Too Old, No Replies

Opening Window Clear Main Window

Should be a simple question

         

kriskd

8:09 pm on Jul 17, 2004 (gmt 0)

10+ Year Member



I'm still a newbie at javascript, so please bare with me. Hopefully the solution will be real simple. I have the following code:

</a> <a href="javascript:window.open('oldnews.html', 'displayWindow', 'width=680,height=400,scrollbars=yes')">Old News</a>

Works great, except when that smaller window is open the main window goes blank with just the text [object] on it.

What am I missing?

kriskd

9:08 pm on Jul 17, 2004 (gmt 0)

10+ Year Member



Cancel my request. I found a tutorial that provided what I needed. I was missing the void operator.

Bernard Marx

9:19 pm on Jul 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Solution:

...scrollbars=yes'); [blue]void 0;[/blue]">

The page will go to the value of the last statement (it's an href). The [object] you are getting is the object reference (to the new window) returned by the open() method.

I think many here would in fact suggest this instead:

<a href="oldnews.html" onclick="window.open(..as before..);return false;">

If Javascript is enabled, it works normally, but the

return false
prevents the
href
link being followed. If JS is disabled, then the main page goes there instead, so at least they get there somehow.