Link to home
Start Free TrialLog in
Avatar of Trevor013097
Trevor013097

asked on

More control over Javascript Windows

I am launching a new window from the first page of a site within which everything will then be loaded.

My question is how can I get the opening window to either close or minimise after if has opened my new window.  What I want to be left with is just the window in the middle of the screen without the opener in the background.

My base platform is IE4.  I have searched everywhere for a solution but non has been forthcoming.  Also is it possible when opening the window to get rid of the really annoying controlbar at the top.  I have everything turned off that I know of but I still have the thick controlbar at the top.  If it can't turned off can it be made thinner?

At the moment I am just using a pretty standard opener script:-

var newWindow;
winOpts='menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,width=570,height=380';

      self.name = 'opener';
      Urlvar = "index2.htm";
      PCMBrowser = window.open(Urlvar,'newWindow',winOpts);

I'll start the points at 50 incase (as I suspect) the answer comes back as "Not Possible".  If it starts getting interesting I'll up the points.

Trevor.
Avatar of Trevor013097
Trevor013097

ASKER

Edited text of question
Try to use the self.close(); command. (with an onBlur option ore something like that)
onBlur="self.close();"
You could use close(), as jbrugman sais, but even just after the open(), i guess.

window.open(Urlvar, ...);
window.close();

About the control bar: do you mean the "titlebar"?
If so, there's a "titlebar" Window's feature, but it has been implemented in NN4 (IE4), and to set it to "no", you need a signed script.

Regards, julio
Must be the heat (26 is hot for the UK!!) but I didn't even think of close();

however there is a problem with that method.  IE4 prompts you to confirm you wish to close the window with the message:-

-----
The web page you are viewing is trying to close the window.

Do you want to close the window?

Yes     No
-----

With regards the controlbar, yes I am referring to the title bar, what exactly is a signed script and how would I get one to do what I want.  Is it simply a Javascript which has been produced with a certificate which you tell your browser to accept as with Applets etc.

Trevor.

To unconditionally close() a window you again need signed scripts.

Here are some additional infos from Netscape's JS Reference:

"The close method closes only windows opened by JavaScript using the open
method. If you attempt to close any other window, a confirm is generated, which lets
the user choose whether the window closes. This is a security feature to prevent "mail
bombs" containing self.close(). However, if the window has only one document
(the current one) in its session history, the close is allowed without any confirm. This
is a special case for one-off windows that need to open other windows and then
dispose of themselves."

About signing scripts, i've never done that, but have - again from Netscape site - downloaded a "JS Security Guide" (76Kb). Cannot remember the Url, but you should easily be able to find it in Netscape's developer corner, or give me your mail address so that i can send you the stuff.

-julio
julio,

I don't need to worry about the close() security restriction having read your offering.  I am developing a front end for a CD-ROM which uses the autorun to launch index.html which then in turn uses window.open to give me a flotaing window without the usual IE baggage which looks more like the sort of menu system you get on coverdisks.

Seeing as the window I wish to close has no history it won't prompt for the confirm.  In my tests so far I had of course loaded something else and then opened the page manually and hence had a history.

If you would liek to post an answer I'll grade it 'A'.  If you think the points are a bit low then just say.

Trevor.


julio,

Just tested the close() having loaded the first page directly, so that there was not a history and it still prompted me on closing.

Any thoughts?


If the browser is already open for any reason, you will get the prompt.

The first alternative, as somewhat described before, is to load a new window, e.g.,

<SCRIPT LANGUAGE="javascript">
<!-- Engage cloaking device

parentwinattr=window.open("filename.html", 'parentwinHome', "width=445,height=475,toolbar='NO',directories='NO',menubar='NO',status='NO',scrollbars='NO',copyhistory=1")
var helpWin=null;
self.close();

// Disengage cloaking device -->
</SCRIPT>

Alternatively, you can try adding a statement to your BODY tag:

ONLOAD="window.open('filename.html' target='_parent')"

which would put the filename back into the parent window without technically closing it. You can also write a function for the window.open statement above and substitute it in the BODY tag ONLOAD= parm.

Brian
btphelps,

That still comes up with the same problem, I get a prompt to close the window even though I double-clicked on the file from explorer.

Why, if I am supposed to be able to close it without prompt if history is empty, am I still getting a prompt.  If I have a default page set in my options will this always be in my history even if I double-click a different file to open the browser?

Trevor.
I've tried this on NN4.04, and it works as expected (even if i do have a home page set):

--//--
<HTML>
  <HEAD>
    <SCRIPT LANGUAGE="Javascript"><!--
      function doLoad() {
        self.open("next.htm");
        self.close();
      }
    // --></SCRIPT>
  </HEAD>
  <BODY onLoad="doLoad()">
  </BODY>
</HTML>
--//--

?? julio
Have you tried closing the original window from within the new one?

if (windowName)  windowName.close();
I did a lot of research, experimentation, and trial and error on this topic as I built a custom, cross-platform  HTML/JavaScript help system using pop-up windows earlier this year.

While  Netscape says that a brand new browser session opened with window.open, when closed using self.close() or its ilk,  will not display a prompt, for some reason no one at Microsoft read Netscape's documentation. IE4, in my experience, _always_ displays the prompt. No workaround I found got rid of it. I believe the ONLOAD..._top trick worked to avoid the prompt in Navigator 4.04, which has a bug having to do with self.close(), but it didn't work in IE4.

I don't think there is a solution to this question. Call this an answer if you want, though not the one you want to get.

Brian
IE can run in Kiosk mode, can't you have a shortcut on the cd with
iexplore -k file:\index.html

That would allow you to have a background of choice in index.htm and open a new page on top of that except a possible problem is MSIE not liking location.hrefs to be changed locally.

Now you have a full screen, no menues or bars perhaps it isn't needed anymore...

Avatar of Michel Plungjan
mplungjan,

Absolutely brilliant.  Where on earth did you find the kiosk mode documented.  It is even better than what I asked for.  Submit an answer and the points are yours.

Sorry I couldn't give points to everyone but in all fairness mplungjan has come up with a suitable solution for IE which I did specify in my original question whereas all others were for NN4.

Trevor.

IE can run in Kiosk mode, can't you have a shortcut on the cd with
iexplore -k file:\index.html

Glad to be of service, did take some testing first...

Michel
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The onLoad within the IFRAME was something else I was testing and is not relevant to the self closing.

Trevor.


It does not do anything in MSIE 3.02 - not even after loading the page containing the iframe as a new window....

Good idea, though

Michel
Maybe it will only work in IE4, thats what I tested it one.

Trevor.

Sorry, I do not currentlyhave access to ie4

Michel