PDA

View Full Version : HELP - How to auto close a window that onload opened a centred popup


2deep
05-07-2003, 05:55 PM
HI there guys I need some help writing the code to pop up a window and close the one that it auto loaded from for the following little situation I need to work around.

OK what I need to do is have a html page that onload of that page opens a centred 650 by 300 auto centred, vertical scrollbars only pop up window. (Simple so far hey)

Ok now what I need to happen is for the page that auto loaded the popup to automatically close therefore the only window that will be open will be the popup that I have just generated.

I know you will probably be “thinking why on earth …..” .
The problem arises because I am calling the 1st html page (the one containing the onload centre window function) from an external .txt file that is formatted and held within a flash (.swf) file.

Flash currently only supports basic html to date and therefore the reason why I need to call a normal _blank page rather than jumping straight to the popup. BTW – I know that flash can open popups and all that. As I say the reason is because I am launching the window from an externl .txt source rendered as HTML in the flash page. Using the simple:

<a href="http://www.2deep.uk.com" target="_blank"><font color="#ffffff" size="10"><u>CLICK HERE TO LAUNCH</u></font></a>

And this is a sophisticated as Flash HTML currently can get, Hence my problem

Thanks in advance to the guru that can write the code for me

arnyinc
05-07-2003, 06:08 PM
Basically, you can't close a window unless you opened it. Is the window, that you're trying to close, a window that you popped up or is it their browser?

There is "kind of" a way around this, but most people do not want you arbitrarily closing their browser. What if they want to go back?

2deep
05-07-2003, 06:21 PM
HI arnyinc Thanks for the reply

Right just to give you the full lowdown.
Ok I have a full flash website that in it has a news feed that takes its content text from an external .txt file. The news feed can contain links to other pages only using the:

<a href="http://www.2deep.uk.com" target="_blank"><font color="#ffffff" size="10"><u>CLICK HERE TO LAUNCH</u></font></a>

which is written in the .txt file and rendered at html through flash.

Now what I want to do is ideally just load a popup from the .txt file, but this is not possible due to flashes simple html support when rendered from a .txt file.

So what I need to do is load the window using the above code.
Then have an auto load on that window that loads the popup. Then closes the window that just contains the onload script.

The reason for the close window part. Is because there is now 3 window open 1. Flash site 2. Blank html page that just contain the onload popup window script 3. The popup window containing the info that I am trying to display, therefore the window that will be closed will be the 2nd one being the blanc one with nothing in it. The reason i want it to close automatically is because it is completely pointless apart from acting as a bridge to get to what I need. The popup !

Therefore there will now be 2 windows open. The flash site and the popup - Man if only it was that easy hey !

Pissing people off about closing browser windows will not be an issue as they will be viewing the flash site and not at all bothered about the html bridge popup window then close page

Thanks for any help you can provide

arnyinc
05-07-2003, 09:04 PM
Ok, now I think I understand.

window 2 should be something simple like this:

<html>
<head>
</head>
<body onload="window.open('window3.htm')">
</body>
</html>

and window 3 needs to have this in the onload event.
<body onload="opener.window.close();">

RoyW
05-07-2003, 09:47 PM
This one has me confused.

What is the format of the text file?

If the text file contains "exactly" the following text

<a href="http://www.google.com" target="_blank"><font color="#ffffff" size="10"><u>CLICK HERE TO LAUNCH</u></font></a>

Then there is not a lot you can do because the page "http://www.google.com" is the one that would require the script.

You could rewrite the URL to something like
href="launch.htm?http://www.google.com" and in the file launch.htm extract the url from the location.search.

However, I don't think you could close launch.htm without the user being prompted.

Have you tried using a javascript URL?

<a href="javascript:window.open('http://www.google.com');" ><font color="#ffffff" size="10"><u>CLICK HERE TO LAUNCH</u></font></a>


Test to see if that works and if it does you can create you own window open script in the same page as the flash.