#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    RTP, North Carolina
    Posts
    2
    Rep Power
    0

    javascript:window.close() action opened a separate browser window


    I tried to use javascript:window.close() and the action opened a separate browser window with a GUI dialog box containing a message "....do you want to close this window?" When clicked "ok", it closed the new browser window instead of the parent.

    This is what's in the code:
    <A HREF="javascript:window.close()"><font face="Arial" color="#7854A3" style="text-decoration:none"><b>close</b></font></A></br>

    The close action is intended to close the parent window. Is there a way to do this without popping up a new browser window?

    <A HREF="window.history.go(-1); javascript:window.close()"> ?

    Thanks!!
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    19
    Don't close windows you didn't open. Period.
  4. #3
  5. No Profile Picture
    ::::
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2002
    Posts
    64
    Rep Power
    16
    Adios is right; although if you DID open the parent through some of your own code, then it should be possible.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    RTP, North Carolina
    Posts
    2
    Rep Power
    0

    Talking Solution


    FYI, I found a way to do it.

    Using a link to close a window itself, which is opened by ISMP LaunchWebBrowser bean, not by javascript:

    <font face="Arial" onClick="window.close();" color="#7854A3" style="text-decoration:none"><b>close</b></font></br>

    if it's an image:

    <img src="arrow.gif" onClick="window.close();"width="40" height="16" border="0">

    simple enough.

    Smile always!
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    1
    Rep Power
    0

    Closing windows


    The code you offered works great, except for one thing, I was trying to close a parent window from a frame in a frameset of the parent. That does not work. But a variation of your code did work. This is what I did:

    <A href="close.htm" target="_top">Click here to close</A>

    Now here is where I used the varient of your code:

    I created a file that only did one thing, it closed when you open it.

    <HTML>
    <body onLoad="window.close()">
    <h1>Stand by, window closing....</h1>
    </body>
    </html>

    This also closed the window without asking popping up an alert window, asking for permission to close. There may be a better way to do this, but it worked for me, and if it works for anyone else then I have done my part to make this a better world for everyone.
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    1
    Rep Power
    0

    Window.close again problem


    Hello saiart,

    I used ur code to open my homepage as default page.
    <SCRIPT LANGUAGE="JavaScript">
    function fullscreen2(url)
    {
    w = screen.availWidth-10;
    h = screen.availHeight-20;
    features = "width="+w+",height="+h;
    features += ",left=0,top=0,screenX=0,screenY=0";
    features += ",menubar=0,toolbar=0,status=0,location=0";
    poppedwin=window.open(url,'homepage',features)
    mainwindow = window.self;
    mainwindow.opener = window.self;
    mainwindow.close();
    poppedwin.focus()
    }
    </SCRIPT>
    <body onLoad="fullscreen2('http://mainserver/steel/steelfeeds.asp'); return false;">
    </body>
    </html>
    But,
    In one system Windows 2000 Professional it is not prompting the
    "Do u wnat to close the window"
    But for the same Windows 2000 Professional in another system,
    it is asking the "Do u wnat to close the window"
    Note : I setted the IE browser -- Advanced--tools--default settings
    the same thing happens for Win 98 also.
    And in one windows 98 system it closes totally .
    What would be the problem.
    Can u help me out for this
    thanz
    hari
    SE
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Cardiff, Wales, UK
    Posts
    1
    Rep Power
    0

    Re: Closing windows


    Resetting the browser opener to be itself before closing is so simple!

    This would never have occured to me.

    window.self.opener = window.self;
    window.close();

    I am interested as to why it does not work on all your systems. Have both like systems been fully updated with same IE service packs?

    It works perfectly on my W2k Professional system, will try it on XP prof. tomorrow.

    I am initially opening the window via C++ code CreateProcess method.

    In one system Windows 2000 Professional it is not prompting the
    "Do u wnat to close the window"
    But for the same Windows 2000 Professional in another system,
    it is asking the "Do u wnat to close the window"
    Note : I setted the IE browser -- Advanced--tools--default settings
    the same thing happens for Win 98 also.
    And in one windows 98 system it closes totally .
    What would be the problem.
    Can u help me out for this
    Last edited by TomUeber; February 6th, 2004 at 06:25 AM.

IMN logo majestic logo threadwatch logo seochat tools logo