Page 1 of 1

JavaScript - make window as bare as possible

Posted: Wed Oct 20, 2004 3:52 pm
by Chris Corbyn
Hi,

Not been in here for a while. Nice to be back. I'm writing a little password manager application (in php but this concerns javascript) for my new job cos there about 100 passwords I have to remember and regularly change.

Note: The app will only ever be used in Internet Explorer (version 6 i think but it might be 5.5).

I want the web page to open in a window that cannot be resized, does not have a status bar, does not have any toolbars or scrollbars etc. Essentially, I'd like to just be able to see the small page (400x500) and the title bar.

If I can't get rid of all the window features in IE then which ones can I get rid of and how do I do it. I'll be using the onLoad event handler to action the function.

Thanks in advance :-)

Posted: Wed Oct 20, 2004 4:00 pm
by John Cartwright

Code: Select all

location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,fullscreen=no'

Posted: Wed Oct 20, 2004 4:00 pm
by Draco_03
It's a normal javascript popup and you specify all the properties

Code: Select all

function openpicmtl() {
	window.open(path_to_your_popup.php", "", "width=500,height=400,toolbars=no,menubar=no,statusbar=no,resizable=no,scrollbars=no,history=no");
}
that's it

And you create your popup like it was a normal page (onload or whatever you want to put in)
just don't forget the design has to fit in a 500X400

And this code works in any browser (that I know of)

Posted: Wed Oct 20, 2004 4:01 pm
by Weirdan

Posted: Wed Oct 20, 2004 4:04 pm
by Chris Corbyn
Thanks. :D
Is there no way I can do it without having to follow a hyperlink which launches a popup? I was hoping I could just type the url in the address bar then an onLoad event handler in the <body> tag could action a function to strip off the window features.

Posted: Wed Oct 20, 2004 4:05 pm
by John Cartwright

Code: Select all

<body onload="javascript:openpicmtl()">

Posted: Wed Oct 20, 2004 4:09 pm
by Draco_03
well yeah the onload will just open a new windows and keep your actual windows with whatever there is on it

Posted: Wed Oct 20, 2004 4:15 pm
by Weirdan
Draco_03 wrote:well yeah the onload will just open a new windows and keep your actual windows with whatever there is on it
adding

Code: Select all

window.opener.close();
to onLoad handler of opened window solves this problem. But still there is a need to have two windows (for a short time).

Posted: Wed Oct 20, 2004 6:26 pm
by Chris Corbyn
Thanks Weirdan. Your point gave me the right idea on how to do it.

1. Go to the url of a page that has onLoad="<Some function to open the new window>"
2. New window opens and then kills the window that opened it.

Pretty much the same as having a window change its features onLoad but you'd see a window bounce out and one disappear. One question....

would a firewall with a built in popup blocker (or just a popup blocker for that matter) prevent my code from working if i did this? I'd rather not have to click a button or link to launch the function. I could live with it though but I guess I'm just being picky :roll:

Posted: Wed Oct 20, 2004 6:44 pm
by John Cartwright
popup blockers should stop the popup

Posted: Thu Oct 21, 2004 4:55 am
by Weirdan
Phenom wrote:popup blockers should stop the popup
Pretty logical, I'd say :) They are popup blockers, after all :lol:

Posted: Thu Oct 21, 2004 8:36 am
by Draco_03
yeah but any good popup blocker will show you somehow that a popup has been blocked, and the user can always unblock your site.

Posted: Thu Oct 21, 2004 11:49 am
by no_memories
99% of the population isn't that logical draco... lol Most just see some annoying error on the browser and ignore it. I've seen how people treat any software by having to actually teach people on site how to use various things. If anything out of the ordinary happens, they usually give a blank stair like the computer has anally violated them or something.

For any popup, I would suggest (especially for today's auto popup blockers) using the "onclick" method. For instance:

Edited: This method along with the actual java script would avoid the popup blocking ability of the onload method. Just use a simple link for the information. To add another window, add another function and call it another name - makewin2. To have a window with scroll bars and such, make the value from 0 to 1

Code: Select all

// Window 1;
  function makeWin(url, p_Width, p_Height) &#123;
    agent = navigator.userAgent;
    windowName = "Sitelet";
    params  = "";
    params += "toolbar=0,";
    params += "location=0,";
    params += "directories=0,";
    params += "status=0,";
    params += "menubar=0,";
    params += "scrollbars=0,";
    params += "resizable=0,";
    params += "width=100,";
    params += "height=100";

  // close the window to vary the window size
  if (typeof(win) == "object" && !win.closed)&#123;
    win.close();
&#125;

    win = window.open(url, windowName , params);

  if (agent.indexOf("Mozilla/2") != -1 && agent.indexOf("Win") == -1) &#123;
    win = window.open(url, windowName , params);
&#125;

  if (!win.opener) &#123;
    win.opener = window;
&#125;

  // bring the window to the front
    win.focus();
&#125;

Code: Select all

<a href="javascript:makeWin('http://yourdomain.com/winpop1.html')">Link</a>