468,107 Members | 1,321 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

How to use window.open() ?

Les
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 could help me here...?

I'd like to use the window.open() script to open a separate window, because I'd like to hide the menubar and specify the
window size as well. So I specify "javascript:window.open(...)" as the HTML link for a hotspot. However, when I test it, I get 2
windows open. One of them is the actual window which was specified by the open() script and that contains what I need, but I have
another window opens as well, which says "[object]".

Why is this other window opens up? How can I get rid of that? Is there's something wrong with the way I specified the
"window.open()" string in the link box. Can anyone tell me what is the correct way?

Thanks!

Les

Jul 20 '05 #1
6 7977
Lee
Les said:

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 could help me
here...?

I'd like to use the window.open() script to open a separate window, because I'd
like to hide the menubar and specify the
window size as well. So I specify "javascript:window.open(...)" as the HTML link
for a hotspot. However, when I test it, I get 2
windows open. One of them is the actual window which was specified by the open()
script and that contains what I need, but I have
another window opens as well, which says "[object]".

Why is this other window opens up? How can I get rid of that? Is there's
something wrong with the way I specified the
"window.open()" string in the link box. Can anyone tell me what is the correct
way?


Your mistake is in the use of the javascript: protocol. By design, it
replaces the contents of the current window with the evaluation of the
expression. The expression "window.open(...)" evaluates to a window
object, which appears in the current window as "[object]".

You can prevent this by either making sure that the expression evaluates
to void, in which case the current window contents are not changed:
javascript:void(window.open(...))
would probably do that.

Better practice would be to avoid using the javascript: protocol, and
to use the onClick event handler, as in:

href="#" onclick="window.open(...);return false"

The ";return false" tells the browser not to load the value of the
HREF attribute.

Jul 20 '05 #2
Lee wrote:
Better practice would be to avoid using the javascript: protocol, and
to use the onClick event handler, as in:

href="#" onclick="window.open(...);return false"


No, bester practise would be to make the href a useful URI ...

href="myfile" onclick="window.open(this.href); return false;"

.... better yet would be avoid opening a new window altogether.

--
David Dorward http://dorward.me.uk/
Jul 20 '05 #3
Lee
David Dorward said:

Lee wrote:
Better practice would be to avoid using the javascript: protocol, and
to use the onClick event handler, as in:

href="#" onclick="window.open(...);return false"


No, bester practise would be to make the href a useful URI ...


Normally, I would have said so, but the context seems to be an automated
menu system, so JavaScript seems to be a requirement, anyway.

Jul 20 '05 #4
DU
Lee wrote:
David Dorward said:
Lee wrote:

Better practice would be to avoid using the javascript: protocol, and
to use the onClick event handler, as in:

href="#" onclick="window.open(...);return false"


No, bester practise would be to make the href a useful URI ...

Normally, I would have said so, but the context seems to be an automated
menu system, so JavaScript seems to be a requirement, anyway.


Where did you get that impression? Even if it was a menu system, why
would it make any difference? Why would "javascript" be an adequate
requirement for the value of an href attribute? "javascript" is still
not a valid protocol.

Top Ten Web-Design Mistakes of 2002
6. JavaScript in Links
http://www.useit.com/alertbox/20021223.html

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #5
Les
Thanks guys, I will try it.
Jul 20 '05 #6
JRS: In article <vn************@corp.supernews.com>, seen in
news:comp.lang.javascript, Les <ju******@nowhere.net> posted at Tue, 30
Sep 2003 14:57:15 :-

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 could help me
here...?


By composing text within a right margin of about 72 characters, in
accordance with standard Usenet recommendation, you can make your
material more readily readable to those with standard 72-column eyes or
80-column display windows.

<FAQENTRY> Jim, I don't see a mention of posting margin or line-wrap in
2.3 </FAQENTRY>.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Michael | last post: by
13 posts views Thread by Kai Grossjohann | last post: by
10 posts views Thread by Marshall Dudley | last post: by
2 posts views Thread by Samir Pandey | last post: by
3 posts views Thread by NeverLift | last post: by
14 posts views Thread by D. Alvarado | last post: by
6 posts views Thread by G Dean Blake | last post: by
7 posts views Thread by anthony.turcotte | last post: by
3 posts views Thread by Andrew Poulos | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.