How to use window.open() ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Les

    #1

    How to use window.open() ?

    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:win dow.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.ope n()" string in the link box. Can anyone tell me what is the correct way?

    Thanks!

    Les





  • Lee

    #2
    Re: How to use window.open() ?

    Les said:[color=blue]
    >
    >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:win dow.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?[/color]

    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(...);retu rn false"

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

    Comment

    • David Dorward

      #3
      Re: How to use window.open() ?

      Lee wrote:
      [color=blue]
      > Better practice would be to avoid using the javascript: protocol, and
      > to use the onClick event handler, as in:
      >
      > href="#" onclick="window .open(...);retu rn false"[/color]

      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/

      Comment

      • Lee

        #4
        Re: How to use window.open() ?

        David Dorward said:[color=blue]
        >
        >Lee wrote:
        >[color=green]
        >> Better practice would be to avoid using the javascript: protocol, and
        >> to use the onClick event handler, as in:
        >>
        >> href="#" onclick="window .open(...);retu rn false"[/color]
        >
        >No, bester practise would be to make the href a useful URI ...[/color]

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

        Comment

        • DU

          #5
          Re: How to use window.open() ?

          Lee wrote:
          [color=blue]
          > David Dorward said:
          >[color=green]
          >>Lee wrote:
          >>
          >>[color=darkred]
          >>>Better practice would be to avoid using the javascript: protocol, and
          >>>to use the onClick event handler, as in:
          >>>
          >>> href="#" onclick="window .open(...);retu rn false"[/color]
          >>
          >>No, bester practise would be to make the href a useful URI ...[/color]
          >
          >
          > Normally, I would have said so, but the context seems to be an automated
          > menu system, so JavaScript seems to be a requirement, anyway.
          >[/color]

          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
          Every year brings new mistakes. In 2002, several of the worst mistakes in Web design related to poor email integration. The number one mistake, however, was lack of pricing information, followed by overly literal search engines.


          DU
          --
          Javascript and Browser bugs:

          - Resources, help and tips for Netscape 7.x users and Composer
          - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x


          Comment

          • Les

            #6
            Re: How to use window.open() ?

            Thanks guys, I will try it.


            Comment

            • Dr John Stockton

              #7
              Re: How to use window.open() ?

              JRS: In article <vnjv22d1usai29 @corp.supernews .com>, seen in
              news:comp.lang. javascript, Les <junkmail@nowhe re.net> posted at Tue, 30
              Sep 2003 14:57:15 :-[color=blue]
              >
              >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...?
              >[/color]

              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.demo n.co.uk/js-index.htm> JS maths, dates, sources.
              <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

              Comment

              Working...