Web Analytics Made Easy -
StatCounter how to own a window and then close it(my own site) - CodingForum

Announcement

Collapse
No announcement yet.

how to own a window and then close it(my own site)

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

  • how to own a window and then close it(my own site)

    hi ,
    can anyone help me as to how to close a window i opened with a javascript link. i tried normal window.close(), but i believe i have to own the wondow before i can close it! and how do i go about doing it? i dont want the bugging confirmation also asking that some script is trying to close the webpage. and if i want to close of not..
    anyone has an answer?
    -Ankur

  • #2
    Where are you trying to close the window from? From the page that you opened it from or from within the actual window that you opened?
    ||||If you are getting paid to do a job, don't ask for help on it!||||

    Comment


    • #3
      from a window i opened.

      using: window.open('*****.html','','scrollbars=no,menubar=no,height=400,width=600,resizable=no,toolbar=no,l ocation=no,status=no');
      i am using it in my geocities site.

      and for closing i am using:
      <a href="javascript:window.close()">

      a i making sense ? or answering u wrong?
      -Ankur

      Comment


      • #4
        Okay so you have
        Code:
        <a href="javascript:window.close()">
        on the page that is opened correct? Okay try this
        Code:
        <a href="#" onclick="window.close();return false">Close Window</a>
        ||||If you are getting paid to do a job, don't ask for help on it!||||

        Comment


        • #5
          nope did not work!

          the link did not work. and when i use the code u provided on a page i open directly... it still asks me for the confirmation!
          :-(..........

          Comment


          • #6
            So you don't get confirmation:

            window.opener=self;
            window.close();
            Single Paradox
            My Site (Under construction)

            Not too bad for a 15 year old

            Comment


            • #7
              ^^ won't work under XP SP2
              *keep it simple (TM)

              Comment


              • #8
                Hmm, I'm sorry, worked for me and I am XP of some sort lol.
                Single Paradox
                My Site (Under construction)

                Not too bad for a 15 year old

                Comment


                • #9
                  That is an exploit of a bug. You can't rely on it to work all the time.
                  This article shows the exploit of this bug and the list of browsers the exploit works.
                  The article is rather old and released before IE XP SP2.

                  But if I were you, I would just leave the confirmation dialog alone. Or don't close the opener window in the first place, as it is unethical to do it.
                  Glenn
                  vBulletin Mods That Rock!

                  Comment


                  • #10
                    Originally posted by glenngv
                    don't close the opener window in the first place, as it is unethical to do it.
                    ... because in these days of tabbed browsing, you'd be closing any websites open in tabs, too, which would probably upset the user. it would certainly annoy me, to the point that I'd never return to your site. i'm sure others would feel like that, too.
                    *keep it simple (TM)

                    Comment


                    • #11
                      Ahh so you were trying to close the page that you opened the popup from. That is not how you originally stated your question. You can only close windows using javascript without getting an alert only if the window was opened with javascript in the first place.
                      ||||If you are getting paid to do a job, don't ask for help on it!||||

                      Comment


                      • #12
                        <script>

                        {
                        window.open('windowUrl.com','windowname','attributes');
                        }
                        </script>


                        <a href="javascript:void(0);" onclick="windowname.close();">Close popup</a>
                        Single Paradox
                        My Site (Under construction)

                        Not too bad for a 15 year old

                        Comment


                        • #13
                          Originally posted by Single Paradox
                          <script>

                          {
                          window.open('windowUrl.com','windowname','attributes');
                          }
                          </script>


                          <a href="javascript:void(0);" onclick="windowname.close();">Close popup</a>
                          You were right in your first post, only it was a bug exploit.
                          Your above post is trying to close the popup window and not the opener.
                          But it's still not going to work as windowname is not a window object.
                          The returned object of the window.open() method is the window object.

                          Code:
                          [B]win[/B] = window.open(...);
                          ...
                          onclick="[B]win[/B].close();"
                          But as I said, this is not what the op asked. Just corrected it to avoid confusion to newbies.
                          Glenn
                          vBulletin Mods That Rock!

                          Comment


                          • #14
                            Oops sorry, I was tired when I wrote that, didn't really think about it Thanks Glen.
                            Single Paradox
                            My Site (Under construction)

                            Not too bad for a 15 year old

                            Comment

                            Working...
                            X