HighDots Forums  

How to use window.open() ?

Javascript JavaScript language (comp.lang.javascript)


Discuss How to use window.open() ? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Les
 
Posts: n/a

Default How to use window.open() ? - 09-30-2003 , 05:57 PM






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






Reply With Quote
  #2  
Old   
Lee
 
Posts: n/a

Default Re: How to use window.open() ? - 09-30-2003 , 06:15 PM






Les said:
Quote:
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.



Reply With Quote
  #3  
Old   
David Dorward
 
Posts: n/a

Default Re: How to use window.open() ? - 09-30-2003 , 06:55 PM



Lee wrote:

Quote:
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/


Reply With Quote
  #4  
Old   
Lee
 
Posts: n/a

Default Re: How to use window.open() ? - 09-30-2003 , 07:15 PM



David Dorward said:
Quote:
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.



Reply With Quote
  #5  
Old   
DU
 
Posts: n/a

Default Re: How to use window.open() ? - 09-30-2003 , 09:07 PM



Lee wrote:

Quote:
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



Reply With Quote
  #6  
Old   
Les
 
Posts: n/a

Default Re: How to use window.open() ? - 10-01-2003 , 12:31 AM



Thanks guys, I will try it.



Reply With Quote
  #7  
Old   
Dr John Stockton
 
Posts: n/a

Default Re: How to use window.open() ? - 10-01-2003 , 08:17 AM



JRS: In article <vnjv22d1usai29 (AT) corp (DOT) supernews.com>, seen in
news:comp.lang.javascript, Les <junkmail (AT) nowhere (DOT) net> posted at Tue, 30
Sep 2003 14:57:15 :-
Quote:
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.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.