Click to See Complete Forum and Search --> : Automatic window close...


soulflycrx
06-03-2003, 06:36 PM
Hello. I have a webpage that uses JS. The page automatically opens a pop-up window. This is what that script looks like.


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=748,height=375,left = 144,top = 184');");
}
// End -->
</script>


How can I adjust this script to automatically close the browser window that its on after it does the pop-up?

For example. User goes to my site. Upon entering a window pops up (this window is where the main content of the site is located). I want the page that initiated the pop-up to close once the pop-up has been opened. (There for, the user surfs the website in the pop-up, and the index page has closed itself)

Thanks!

Jona
06-03-2003, 06:41 PM
Put this line right before the last }


window.close();


Jona

geuis
06-03-2003, 07:58 PM
Try this:

http://68.145.35.86/skills/javascripts/CloseParentWindowFromChild.html

Complements khalidali63 for showing this to me originally.

soulflycrx
06-03-2003, 11:34 PM
Woah! That was cool. It didn't require the visitor to approve what you are trying to do as well... Thanks!

Jona
06-03-2003, 11:44 PM
I'm sure Dave knew how to prevent the prompt, as I did; however, it's not a good practice to use this method. For one, as Dave mentioned, it's a security thing. And second, using the code will make others interested, which will spread the code around even more.

Personally, I never put myself in a situation where I would need to override the prompt.

Jona

soulflycrx
06-03-2003, 11:49 PM
well, I am just using it for simple site function. I am not trying to be seedy about it. heh.

Jona
06-03-2003, 11:52 PM
People can look at the source code and figure it out, though. (But come to think of it, good Web developers probably know it, but...)

Jona

geuis
06-04-2003, 07:54 AM
I try to work under the ideas that information should be free. Call me a liberal, but if someone gave me information freely, then I must keep the balance and let it flow forth as well. It is not up to me to decide what are the proper uses of technology. If something can be done, then the information should be shared. Once everyone is aware of something, then if its a problem, there will be fixes introduced.

Perhaps I take my mantra from 2600, since they share the same philosophy. Regardless, that's my 2 cents.