Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Sep 2003
    Location
    australia
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    Hello all.

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

    My JS pop-up script goes like this:

    Code:
      
    <script>
    // pop up function called by dynamic 'listen' links below
    var newwindow = '';
    
    function openpopup(outURL)   {
    
    	if (!newwindow.closed && newwindow.location)
    	{
    		newwindow.location.href = outURL;
    	}
    	else
    	{
    		newwindow=window.open(outURL,'name','left=150,top=200,width=300,height=150,scrollbars=no');
    		if (!newwindow.opener) newwindow.opener = self;
    	}
    	if (window.focus) {newwindow.focus()}
    	return false;
    }
    </script>
    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:
    http://www.devaswami.net/audio.php

    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?

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

    ,
    ekendra

    http://www.devaswami.net/audio.php
    Attached Files Attached Files

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Works fine on mine i.e 6.02

    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

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Just an idea

    Was just thinking (without testing) about the line
    Code:
    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

  • #4
    New Coder
    Join Date
    Sep 2003
    Location
    australia
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 ???


    ekendra

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    New Coder
    Join Date
    Sep 2003
    Location
    australia
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.


    thanks for your help though.


    ekendra

  • #7
    Regular Coder
    Join Date
    Jul 2002
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up I'll have a look after lunch

    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)

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Posts
    165
    Thanks
    0
    Thanked 0 Times in 0 Posts

    WOAH, crashed everything (well just me forum windows)

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •