Multi-function self close question

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

    #1

    Multi-function self close question

    I used javascript to open a new window, then used the following to close the
    new window on the next click:
    <body onBlur="self.cl ose()" onClick="self.c lose()" bgcolor="#FFFFF F">

    On the new window I want to place a link to another website, and I want the
    new window to open the link in ANOTHER new window (not the parent window)
    and then self close.

    The idea is that on the first new window I have a picture, and a link to
    another website that shows more information about the picture. If the person
    just wants to see the picture and go back to my original page, the popup
    window disappears. Or if they want more information they click on the link,
    and another window pops up and the first popup window disappears. That way
    they can look at the new page on someone else's website, and my website page
    is still there for them to go back to.

    Can I edit the <body> line I used to self close after opening a new window?
    I don't want the link to open in the parent window...

    Any suggestions?

    Thanks,
    Ray


  • Michael Winter

    #2
    Re: Multi-function self close question

    On Fri, 13 Aug 2004 06:00:31 GMT, Raymond Wilk <rrwilk@worldne t.att.net>
    wrote:
    [color=blue]
    > I used javascript to open a new window, then used the following toclose
    > the new window on the next click:
    > <body onBlur="self.cl ose()" onClick="self.c lose()" bgcolor="#FFFFF F">[/color]

    My first piece of advice is to not do that. There are many reasons why a
    window might be sent to the background, and I don't think any of them mean
    that the window should close. I frequently shift between page tabs on my
    browser, and even external applications. That's what a multi-tasking
    environment is supposed to allow. I do not expect to come back and find
    that what I was looking gone.

    [snip]
    [color=blue]
    > Can I edit the <body> line I used to self close after opening a new
    > window?
    > I don't want the link to open in the parent window...[/color]

    That, frankly, doesn't make much sense. I assume you mean, "How do I
    modify the <body> line to open a new window, then close the current
    window?" If so, call openThenClose() , below:

    function openThenClose() {
    window.open('th eURL','windowNa me');
    window.close();
    }

    If that isn't what you want, please rephrase your question.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail

    Comment

    • Raymond Wilk

      #3
      Re: Multi-function self close question

      > That, frankly, doesn't make much sense. I assume you mean, "How do I[color=blue]
      > modify the <body> line to open a new window, then close the current
      > window?" If so, call openThenClose() , below:
      >
      > function openThenClose() {
      > window.open('th eURL','windowNa me');
      > window.close();
      > }
      >
      > If that isn't what you want, please rephrase your question.
      >
      > Mike[/color]

      I got that to work, but I'm missing one function I didn't make clear. If the
      link in the window is NOT clicked I would like the window to close.

      After following your advice, I have a window that contains a picture and a
      link to another site. If the link is clicked, the first window closes and a
      new window opens showing the other site. Perfect. But if the person viewing
      the first window just wants to look at my picture and NOT follow the link, I
      would like that window to self close on the next click.

      If I use <body onBlur="self.cl ose()" onClick="self.c lose()"> or just <body
      onBlur="self.cl ose()"> it over-rides what you gave me, and closes the window
      when the link is clicked.

      Thanks for helping me, Mike. I'm a graphics guy and all I know how to do
      with scripts is copy-paste!
      Ray


      Comment

      • Michael Winter

        #4
        Re: Multi-function self close question

        On Sun, 15 Aug 2004 06:33:51 GMT, Raymond Wilk <rrwilk@worldne t.att.net>
        wrote:


        [snip]
        [color=blue]
        > After following your advice, I have a window that contains apicture and
        > a link to another site. If the link is clicked, thefirst window closes
        > and a new window opens showing the other site.Perfect. But if the person
        > viewing the first window just wants tolook at my picture and NOT follow
        > the link, I would like thatwindow to self close on the next click.[/color]

        So,

        1) User clicks on link in main website. This opens new window with
        image a link.
        2a) User clicks link in new window. Second window opens containing web
        page at URL. First window closes.
        2b) User clicks elsewhere in page. First window closes, leaving
        original site.

        That correct? If so, try:

        In first window:

        <head>
        <title>...</title>

        <style type="text/css">
        body {
        bottom: 0;
        position: absolute;
        top: 0;
        }
        </style>
        </head>

        <!-- I still recommend not using onblur="self.cl ose()" -->
        <body onclick="self.c lose()">
        <!-- image -->
        <!-- A button would be better than a link... -->
        <a href="#" onclick="window .open('url','na me');return false;"[color=blue]
        >...</a>[/color]
        </body>

        That does what I've listed above. The style sheet is a kludge to ensure
        that Opera (and possibly other browsers) register the body click anywhere
        on the page. Without it, the body only extends as far as the last element.

        If this *still* isn't correct, I apologise for being so dense. :)

        [snip]

        Mike

        --
        Michael Winter
        Replace ".invalid" with ".uk" to reply by e-mail

        Comment

        • Raymond Wilk

          #5
          Re: Multi-function self close question

          > If this *still* isn't correct, I apologise for being so dense. :)[color=blue]
          >
          > Michael Winter[/color]

          That's exactly what I'm looking for! Thanks again for the help!
          Ray


          Comment

          Working...