Need script to 'OpenWindow' or 'Spawn'

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

    Need script to 'OpenWindow' or 'Spawn'

    - Want to open a 2nd browser window when someone clinks a link with the link
    content inside it.
    - Want to control window size
    - Want all tool bars so only blue bar at top shows
    - Can I put my content in the blue bar?
    - Only options are Minimize, Maximize or Close (top right of blue bar)

    1 - What is the difference in 'OpenWindow' and 'Spawn' ??

    2 - Can anyone point me to a simple script I can use... or just post one...

    I Googled this and everything I find has so many strings attached and wants
    me to 'join' something that it discourages me from geetting proceeding with
    them.

    I just want a simple script and a little coaching on how to implement this.

    Can anybody please help me?

    Thanks - tmb


  • Grant Wagner

    #2
    Re: Need script to 'OpenWindow' or 'Spawn'

    tmb wrote:
    [color=blue]
    > - Want to open a 2nd browser window when someone clinks a link with the link
    > content inside it.
    > - Want to control window size
    > - Want all tool bars so only blue bar at top shows
    > - Can I put my content in the blue bar?
    > - Only options are Minimize, Maximize or Close (top right of blue bar)[/color]

    You can do all of the above (within limits of the user agent's abilities and
    depending on whether some of the above features are excluded from what you can
    achieve in a particular user agent) with the <attributes> parameter of the
    window.open() method.

    The only "content" you can put in the "blue bar" (more commonly called the
    "titlebar", you _do_ know that it's not blue on many, many operating systems
    don't you? and even on operating systems where it is blue, that can be changed
    by the user) is the contents of the <title></title> tags on the new HTML page
    opened in that window.
    [color=blue]
    > 1 - What is the difference in 'OpenWindow' and 'Spawn' ??[/color]

    Neither is a reserved word in Javascript, so they are probably just functions
    written by Javascript authors. OpenWindow is presumably the name of some
    function written by one Javascript author, Spawn is probably a function written
    by another Javascript author. The difference between them would be the code
    inside the functions.
    [color=blue]
    > 2 - Can anyone point me to a simple script I can use... or just post one...[/color]

    <script type="text/javascript">
    function openWindow(lnk) {
    if (window.open) {
    return !window.open(ln k.href, lnk.target,
    'width=400,heig ht=300,resizabl e=1');
    }

    return true;
    }
    </script>
    <!-- example usage -->
    <a href="page.html " target="myNewWi ndow"
    onclick="return openWindow(this );">Test</a>

    The attributes string (3rd parameter of window.open()) is documented at:

    <url:

    />

    Internet Explorer supports a few more attributes (but don't use them unless
    you're only supporting IE):

    <url:
    http://msdn.microsoft.com/workshop/a...ods/open_0.asp />
    [color=blue]
    > I just want a simple script and a little coaching on how to implement this.[/color]

    The problem with a simple script is that you are going to be unaware of the
    issues involved in opening a new window. The conventional wisdom is that on the
    general public Internet, opening a new window is very often the wrong choice. Go
    to groups.google.c om and search comp.lang.javas cript for "open new window" to
    see past discussions on this subject.

    The way my solution is written, if Javascript is enabled, the "onclick" event
    will fire and open the new window with the HREF and TARGET attributes specified
    by the <A> tag. If the opening of the new window _appears_ to succeed (important
    point, _appears_ to succeed, it may, in fact, not have been successful), then
    the link is not followed and processing stops.

    If Javascript is not enabled, or the user agent does not support window.open, or
    window.open() appears to fail, then the link _is_ followed and the page will
    open in a new window anyway (thanks to the TARGET attribute and subject to the
    capabilities of the user agent), you just won't be able to control the size and
    chrome of the new window.

    But even this is not 100% guaranteed to open a new window containing your
    content under every circumstance, in every user agent.

    Please be aware that many, if not all, Web browsers now offer some degree of
    popup blocking (they disable the ability to open new windows). If they do allow
    new windows to be opened, many Web browsers can control the attributes which can
    be applied to those new windows (for example, a new window may open, but it may
    not be the size, or have the chrome that you requested).

    --
    | Grant Wagner <gwagner@agrico reunited.com>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *


    * Internet Explorer DOM Reference available at:
    *
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


    * Netscape 6/7 DOM Reference available at:
    * http://www.mozilla.org/docs/dom/domref/
    * Tips for upgrading JavaScript for Netscape 7 / Mozilla
    * http://www.mozilla.org/docs/web-deve...upgrade_2.html


    Comment

    • tmb

      #3
      Re: Need script to 'OpenWindow' or 'Spawn'

      Grant,

      Just what I needed. Thanks.

      tmb

      "Grant Wagner" <gwagner@agrico reunited.com> wrote in message
      news:40D31CA1.A 1AB6B2A@agricor eunited.com...[color=blue]
      > tmb wrote:
      >[color=green]
      > > - Want to open a 2nd browser window when someone clinks a link with the[/color][/color]
      link[color=blue][color=green]
      > > content inside it.
      > > - Want to control window size
      > > - Want all tool bars so only blue bar at top shows
      > > - Can I put my content in the blue bar?
      > > - Only options are Minimize, Maximize or Close (top right of blue bar)[/color]
      >
      > You can do all of the above (within limits of the user agent's abilities[/color]
      and[color=blue]
      > depending on whether some of the above features are excluded from what you[/color]
      can[color=blue]
      > achieve in a particular user agent) with the <attributes> parameter of the
      > window.open() method.
      >
      > The only "content" you can put in the "blue bar" (more commonly called the
      > "titlebar", you _do_ know that it's not blue on many, many operating[/color]
      systems[color=blue]
      > don't you? and even on operating systems where it is blue, that can be[/color]
      changed[color=blue]
      > by the user) is the contents of the <title></title> tags on the new HTML[/color]
      page[color=blue]
      > opened in that window.
      >[color=green]
      > > 1 - What is the difference in 'OpenWindow' and 'Spawn' ??[/color]
      >
      > Neither is a reserved word in Javascript, so they are probably just[/color]
      functions[color=blue]
      > written by Javascript authors. OpenWindow is presumably the name of some
      > function written by one Javascript author, Spawn is probably a function[/color]
      written[color=blue]
      > by another Javascript author. The difference between them would be the[/color]
      code[color=blue]
      > inside the functions.
      >[color=green]
      > > 2 - Can anyone point me to a simple script I can use... or just post[/color][/color]
      one...[color=blue]
      >
      > <script type="text/javascript">
      > function openWindow(lnk) {
      > if (window.open) {
      > return !window.open(ln k.href, lnk.target,
      > 'width=400,heig ht=300,resizabl e=1');
      > }
      >
      > return true;
      > }
      > </script>
      > <!-- example usage -->
      > <a href="page.html " target="myNewWi ndow"
      > onclick="return openWindow(this );">Test</a>
      >
      > The attributes string (3rd parameter of window.open()) is documented at:
      >
      > <url:
      >[/color]
      http://devedge.netscape.com/library/...ce/frames.html[color=blue]
      > />
      >
      > Internet Explorer supports a few more attributes (but don't use them[/color]
      unless[color=blue]
      > you're only supporting IE):
      >
      > <url:
      >[/color]
      Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

      />[color=blue]
      >[color=green]
      > > I just want a simple script and a little coaching on how to implement[/color][/color]
      this.[color=blue]
      >
      > The problem with a simple script is that you are going to be unaware of[/color]
      the[color=blue]
      > issues involved in opening a new window. The conventional wisdom is that[/color]
      on the[color=blue]
      > general public Internet, opening a new window is very often the wrong[/color]
      choice. Go[color=blue]
      > to groups.google.c om and search comp.lang.javas cript for "open new window"[/color]
      to[color=blue]
      > see past discussions on this subject.
      >
      > The way my solution is written, if Javascript is enabled, the "onclick"[/color]
      event[color=blue]
      > will fire and open the new window with the HREF and TARGET attributes[/color]
      specified[color=blue]
      > by the <A> tag. If the opening of the new window _appears_ to succeed[/color]
      (important[color=blue]
      > point, _appears_ to succeed, it may, in fact, not have been successful),[/color]
      then[color=blue]
      > the link is not followed and processing stops.
      >
      > If Javascript is not enabled, or the user agent does not support[/color]
      window.open, or[color=blue]
      > window.open() appears to fail, then the link _is_ followed and the page[/color]
      will[color=blue]
      > open in a new window anyway (thanks to the TARGET attribute and subject to[/color]
      the[color=blue]
      > capabilities of the user agent), you just won't be able to control the[/color]
      size and[color=blue]
      > chrome of the new window.
      >
      > But even this is not 100% guaranteed to open a new window containing your
      > content under every circumstance, in every user agent.
      >
      > Please be aware that many, if not all, Web browsers now offer some degree[/color]
      of[color=blue]
      > popup blocking (they disable the ability to open new windows). If they do[/color]
      allow[color=blue]
      > new windows to be opened, many Web browsers can control the attributes[/color]
      which can[color=blue]
      > be applied to those new windows (for example, a new window may open, but[/color]
      it may[color=blue]
      > not be the size, or have the chrome that you requested).
      >
      > --
      > | Grant Wagner <gwagner@agrico reunited.com>
      >
      > * Client-side Javascript and Netscape 4 DOM Reference available at:
      > *
      >[/color]
      http://devedge.netscape.com/library/...ce/frames.html[color=blue]
      >
      > * Internet Explorer DOM Reference available at:
      > *
      >[/color]
      http://msdn.microsoft.com/workshop/a...ence_entry.asp[color=blue]
      >
      > * Netscape 6/7 DOM Reference available at:
      > * http://www.mozilla.org/docs/dom/domref/
      > * Tips for upgrading JavaScript for Netscape 7 / Mozilla
      > * http://www.mozilla.org/docs/web-deve...upgrade_2.html
      >
      >
      >[/color]


      Comment

      Working...