Web Hosting Talk







View Full Version : PopUp Window & Automatic Close


gcjeepster
10-07-2002, 07:27 PM
Does anyone know of a script that will allows you to open a blank page that immediate opens a new window/page(a redirect scenario) and then closes the original blank page that had the redirect script without user intervention?

I have the script that will open a new window/page but leaves the original page open requiring the user to manually close the blank window.

Your assistance would be greatly appreciated.

DefiantPc
10-07-2002, 07:48 PM
You can try this but I think it will ask you if you want to close the window.
The 3000 is 3 seconds you can change this.


<SCRIPT LANGUAGE="JavaScript">
function closeWin(){
window.close()
}
function timer(){
timerID = setTimeout("closeWin()", 3000)
}

</SCRIPT>
<script>
timer();
</script>



Just wondering why you dont want a straight redirect as in have it open the new page in self?

Maybe you could explain what your trying to do.

-Mj.

kyun
10-07-2002, 08:07 PM
I'm not exactly sure what you mean (and why you need it :) ), but if it's what I think, this can be done.

1.html
<body onload="win1=window.open('2.html');win1.close()">

2.html
<body onload='window.open()'>

gcjeepster
10-07-2002, 08:34 PM
Yes, it does prompt the user to click ok to close the window. Here is what I am doing....

I have a page that when that page loads, it calls a script which acts as a counter and opens the desired landing page.

For instances, a user goes to receives a marketing email where the hits to the desired landing page are needed. User goes to http://www.domainname.com/explode/index.htm where instantly this page marks a hit against the statistics counter script and directs the user to http://www.domainname.com.

Right now... the original page remains in the background until the user closes it OR they are prompted through the script you listed to confirm closing that window. I need the original page to close after a few seconds without requiring any response from the user... in essence, the original page/browser window just disappears.

I hope this helped.


Originally posted by DefiantPc
You can try this but I think it will ask you if you want to close the window.
The 3000 is 3 seconds you can change this.


<SCRIPT LANGUAGE="JavaScript">
function closeWin(){
window.close()
}
function timer(){
timerID = setTimeout("closeWin()", 3000)
}

</SCRIPT>
<script>
timer();
</script>



Just wondering why you dont want a straight redirect as in have it open the new page in self?

Maybe you could explain what your trying to do.

-Mj.

getweb
10-07-2002, 09:09 PM
A javascript can close any child windows or I believe itself if opened by script, but that's it. (Anything else will get that warning.)

A child could redirect a parent window though. What about a popup window that records the hit, redirects the original window to the target page, and closes itself? (In fact, I think Kazaa does this as well as many other sites/apps.)

Anyway, I really am asking, so if there's a reason that doesn't work for you try to give more detail as to why. Somebody will have a solution.

DefiantPc
10-07-2002, 09:29 PM
Paste the below into the head area of the HTML .
Your counter will record the hit before it is redirected to the landing page.

<META content="2;url='http://www.yourdomain.com/js/'" http-equiv=refresh delay="2">

It wont open a pop but it should do what your asking, that is if I am understanding you correctly.

-MJ.