PDA

View Full Version : Current page says "[object]"


Morgoth
03-30-2003, 05:43 PM
Hello,

Quick and Breif...

Popup in a href; This is what I want to do:

<a href="javascript:window.open('PAGE.html','PAGE','width=400,height=350')">


It works, but when I click on it, the current window (parent) says "[object]"

Can this be fixed without having to use <script> tags?

Thank you.

scroots
03-30-2003, 05:47 PM
you need to make it something like this

java script:window.open("'PAGE.html','PAGE','width=400,height=350'")

notice the (" and ") thouse quotes will need to be escaped with a slash to avoid wrecking your link.

scroots

Morgoth
03-30-2003, 07:59 PM
What do you mean?

javascript:window.open("'PAGE.html','PAGE','width=400,height=350'")

I can't use " or else my link wont work...

Please be more specific...

Morgoth
03-30-2003, 08:08 PM
Hum..
Well, either way, I have this working:



<a href="javascript://" OnClick=javascript:window.open("PAGE.html","PAGE","width=400,height=350")>LINK</a>

scroots
03-30-2003, 08:46 PM
like using \" or "/ or whatever it is
its either
"\
"/
\"
/"

scroots

jkd
03-30-2003, 09:15 PM
Just surround your window.open() command inside a void().

Morgoth
03-30-2003, 10:52 PM
scroots: It's not a string, I am not allowed to do that.

jkd: Void() works... Thank you.

cheesebagpipe
03-30-2003, 11:42 PM
This is probably the most versatile way of doing this:

<a href="PAGE.html" target="_blank" onclick="window.open(this.href,'PAGE','width=400,height=350');return false;">

JS-enabled users get the sized window, -disabled ones get a default window, and nobody gets hurt. The [object] you were seeing displayed is the new window object, returned by window.open(), passed along to the default action of the link, which is, naturally, to open a new page in the (main) window. No way to 'display' an object, so the Object.toString() method simply outputs '[object]' (NS: '[object window]'), which becomes your new 'web page'. The false return cancels the event.

Morgoth
03-31-2003, 02:41 AM
Wow cheesebagpipe, that was a great addition!

Thank you so much!

Also, many thanks to jkd and scroots!


It doesn't bother me a lot (instead of posting a request or bothering to do a search myself (Lazy or Busy? You decide...) I will ask here), but is there away to set a possition of the window that opens up? Like, force it to open up the new window at 0,0 (top, left) of the users screen? (It's a large window, and might be the best place for it.)

Thanks again...

Roelf
03-31-2003, 06:52 AM
in the last argument of the window.open() method, add the left and top variable to the width and height, like
window.open("page.html", "windowname", "width=200,height=200,left=0,top=0")
dont know if this works in other than IE

Morgoth
03-31-2003, 01:11 PM
Roelf

Well, as long as it works with IE, I think I will be fine...

Thank you.