Help - Search - Members - Calendar
Full Version: Java Script Window.Open Issue
Invision Power Services > Community Forums > Community Web Design and Coding
Michael Boutros
Hello,

I am having a small issue using java script:window.open in a link. The new window opens fine and all, but the problem is that the window where the link is clicked disappears and the text "[object Window]" appears. Below is the code for the link.

CODE
    $preview_link = "<a href=\"java script:window.open('core/preview.php?url=$url&title=$title','Preview $title','width=600,height=800')\">Preview</a>";


Thanks,
Michael Boutros
Stephen
Change the link to

CODE
<a href="java script:void(0);" onclick="java script:window.open('core/preview.php?url=$url&title=$title','Preview $title','width=600,height=800');">Preview</a>


notice that there no space between the a and s in the "javascript" prefix (which isn't actually needed on event handlers such as onclick, so you could remove it if you wish)

original.gif
Rikki
It's not really a good idea to void the normal action of a link... I'd do:

CODE
<a href="core/preview.php?url=$url&title=$title" onclick="java script:window.open('core/preview.php?url=$url&title=$title','Preview $title','width=600,height=800');">Preview</a>


That way, if they have Javascript, they get the popup, if they don't, they still get to see the preview original.gif
Stephen
pretty sure that way you'd get both the popup and the main window showing the link.

You'd need

QUOTE
<a href="core/preview.php?url=$url&title=$title" onclick="java script:window.open('core/preview.php?url=$url&title=$title','Preview $title','width=600,height=800'); return false;">Preview</a>
Rikki
Oops, yeah you're right.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.