View Full Version : JS pops-up a new window but renders links on original page dead ?!?!?!

10-03-2003, 12:22 PM
Hello all.

I have a JS problem here that's got my brain in a knot.

My JS pop-up script goes like this:

// pop up function called by dynamic 'listen' links below
var newwindow = '';

function openpopup(outURL) {

if (!newwindow.closed && newwindow.location)
newwindow.location.href = outURL;
if (!newwindow.opener) newwindow.opener = self;
if (window.focus) {newwindow.focus()}
return false;

I guess that's pretty straightforward. The variable that's passed into this function comes from a PHP variable plugged into an "onClick" call in a text link.

The problem comes not the first time a link is clicked. (the pop-up opens fine, does what its supposed to do). Not the second time a link is clicked (once again it works fine.) The problem comes when the pop up function has to open a new window the third time. What happens is : the links on the calling page go dead. (try downloading something afterwards - no luck) and the pop-dosen't do what it is supposed to do.

try it out live if you like:

If links are clicked consecutively without having to open a new window (stuff is just passed into the already open pop-up) then there is no problem. Only when closing and opening the pop-up on the thrid try does the thing pack itself.

any clues? :confused:

i've included the original PHP script if you'd like a better looka t this.



10-03-2003, 01:25 PM
But then, is there a reason why you have return = false in your function?

Historically I think, return false will cancel whatever you wanted it to do, I also noticed it takes a while to open the popup (it may have worked for me because there are currently errors in the popup so less loading time)

If the return false was triggered before the window managed to open, it may (correct me if I'm wrong) cancel the opening of it

Instead of return false, just set the href to #

<a href="#" onclick="function()"></a>

Hope this helps :)

10-03-2003, 01:39 PM
Was just thinking (without testing) about the line

if (!newwindow.opener) newwindow.opener = self;

Have you tried commenting it out or (i know in theory it should) do you know for a fact that newwindow.opener always exists? maybe it gets confused

10-03-2003, 01:39 PM
Thanks for the quick reply.

The reason the pop-up had an error in it is because I'm messing around with it trying to determine by process of elimination what's going on with it. I've made a little progress in that:

1. When the FLASH movie isn't called in the new pop-up than everything works as per norm. You can open and close as many pop-ups as you like and the download links on the calling page still work ok.

2. When the FLASH movie is called and paramters are passed to it - it stops working on the third time it is opened up in a new pop up.

3. If the pop-up is left open you cal click on 'listen' and send new variables to it as much as you like no problem.

So the problem only occurs when a new pop is opened and a flash movie is started in the new pop-up - on the third time.

I hope there is just something I overlooked. Otherwise I think there is a bug here that MS or Macromedia didn't iron out. Not a JAVASCRIPT problem.

I'll remove the 'return false' from my JS anyway though because its' redundant.

any ideas ???


10-03-2003, 01:57 PM
hmmm, well, I havent played with flash much - but I guess you've checked the parameters ur passing into the movie script?

Can you create a debug file or something which will give you more information, also, another thing to try would be an iframe inside the popup (full page) with frameborder=0 in the tag, then manipulate its location with the querystring, making the window itself always have the same location

This is intuition speaking, but I always find the solution (eventually) ;)

+ might help if you allow one of the links play the movie so we can see it happen

10-03-2003, 02:04 PM
thanks. It's all back up now if you'd like to see the FLASH do its thing. (twice only that is ???)

I'm now thinking of an entire workaround that avoids this pop-up delimna altogether. Mabye I'll just have the whole page in FLASH and let the actionscript do all of its own variable passing and not try to integrate the 2 languages. Shame though cause in theory its supposed to work. I suppose communism was supposed to work in theory too. :p

thanks for your help though. :thumbsup:


10-03-2003, 02:14 PM
Me going to Munchies so back 1 hr - communism... you should speak to my friend from Nham (not the real Nham), viva la Nham revloution, hes always going on about that and capitalism - taking the Micheal out of it/serious too - u 2 would get on (maybe)

till later (or someone else) :D

10-03-2003, 03:39 PM
ok, as its hanging, I still think putting into an Iframe especially for testing would be a good idea, would make debugging the problem easier (have you tried Shockwave player?) its basically the same but maybe not same problem

If you stick the flash movie into an iframe, and do javascript timeout setTimeout("functionname or code", 2000) // 2 seconds to load the movie, you would be able to get a clearer idea of what's going wrong.

Or I would anywayZ, maybe the source is getting copied twice (like appending to the old link or sth) that would stop it working/make it hang - its a problem I've had with similar stuff

Good luck, keep me posted :thumbsup: