Web Analytics Made Easy -
StatCounter Answer me plz its urgent... - CodingForum

Announcement

Collapse
No announcement yet.

Answer me plz its urgent...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Answer me plz its urgent...

    I want to close two browser windows at the same time by clicking on one link in any of the two pages is it possible.

  • #2
    If you opened the windows from a script with the "window.open()" method and named each window, you can close them from the parent window with...
    <script>
    <!--
    function closeWin() {
    window.close(myWin1);//myWin1 is the name of the 1st window
    window.close(myWin2);//myWin2 is the name of the 2nd window
    }
    //-->
    </script>
    then in your html use this for the link.
    <a href="javascript:closeWin()">Close both windows</a>

    At least it should work, you may need quotes around the names, can't remember.
    Create accessible online surveys -::- Koobten.com - compare netbook prices and reviews -::- Affordable, reliable hosting for less than $20 per year
    Zend Certified Engineer

    Comment


    • #3
      The code u gave is working fine when there are two windows which were opened by using the window.open(). But i want to close the two windows in which one is opened in the browser(parent window) and in that i have used the window.open() to open an new window. Now i want to close this both windows from the child window. Is it possible plz help me...

      Comment


      • #4
        This is a shot in the dark, but it might work.

        From the granchild window try this...

        parent.window.parent.window.close()
        parent.window.close();

        I think if you try to close the original parent (grandparent) window an alert box pops up though.
        Create accessible online surveys -::- Koobten.com - compare netbook prices and reviews -::- Affordable, reliable hosting for less than $20 per year
        Zend Certified Engineer

        Comment


        • #5
          No it is not working. Do you have any other idea.

          Comment


          • #6
            it isn't possible to close the main browser window using javascript. it constitutes a security risk, and an invasion of privacy, so there are controls that prevent it from happening.
            bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

            i am a loser geek, crazy with an evil streak,
            yes i do believe there is a violent thing inside of me.

            Comment


            • #7
              simple really...

              I main window opens window 1, and window 1 opens window 2, and you want main window to close both, then define a function in window 1 code that closes window 2.

              Then in main window, do:

              window1.close_window2_function();
              window1.close()

              Comment


              • #8
                <input type="button" value="Close All"
                onclick="if(opener&!opener.closed)opener.close();self.close()">

                This closes both pop-ups...

                Comment


                • #9
                  I found this whilst searching for a script and thought it better to follow in than open a new thread.

                  My site operates mainly from the first broser window that opens. Through necessity though, I do have a pop-up for more specific content.

                  What I need is to be able to load a page from a hyperlink in the pop-up in the main window whilst at the same time closing the pop-up.

                  be getle with me I'm only a learner

                  thanks
                  "The day you stop learning is the day you become obsolete"! - my late Dad.

                  Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
                  Useful MySQL resource
                  Useful MySQL link

                  Comment


                  • #10
                    What I need is to be able to load a page from a hyperlink in the pop-up in the main window whilst at the same time closing the pop-up.

                    This should do the trick:

                    Code:
                    <a href="whereever..." onclick="window.opener.location.href=this.href; window.close; return false;">A link</a>
                    Check out the Forum Search. It's the short path to getting great results from this forum.

                    Comment


                    • #11
                      Thanks but....

                      This is the link as copied from my page (having firstly inserted what you suggested.

                      <a class="standardlink" href="../../folder/document.htm" onclick="window.opener.location.href=this.href; window.close; return false;">

                      It does make the main window change to the desired display but it doesnt close the smaller window. Have I entered the line wrongly or wot?

                      thanks again.

                      Bazz
                      "The day you stop learning is the day you become obsolete"! - my late Dad.

                      Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
                      Useful MySQL resource
                      Useful MySQL link

                      Comment


                      • #12
                        Another possibility: name the 'main' window:

                        <script type="text/javascript" language="javascript">

                        self.name = 'bazzWin';

                        </script>

                        (in all your pages). Then:

                        <a class="standardlink" href="../../folder/document.htm" target="bazzWin" onclick="if(opener&&!opener.closed)opener.location=this.href;self.close();return false;">

                        ...in the pop-up.

                        Comment


                        • #13
                          Cheesebagpipe saw the problem, I left out the () on the window.close() call.
                          Check out the Forum Search. It's the short path to getting great results from this forum.

                          Comment


                          • #14
                            Hey Roy...shouldn't that be...

                            Give me ambivalence or give me something else

                            Comment


                            • #15
                              Originally posted by cheesebagpipe
                              Hey Roy...shouldn't that be...

                              Give me ambivalence or give me something else

                              Naw, ambivalence is an attitide you adopt while ambiguity is something you can receive.
                              Check out the Forum Search. It's the short path to getting great results from this forum.

                              Comment

                              Working...
                              X