A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: target blank and jscript window.opener

  1. #1
    Senior Member
    Join Date
    Apr 2004
    Posts
    156

    target blank and jscript window.opener

    hi

    alright i am targeting a blank window with a link in flash. in this blank window it does not detect a window opener. when i target a blank window with this script with html it works fine. of course this problem only exists in ie6 and ie7 all other browsers are fine.

    has anyone run into this? window.opener not recognizing a parent window when the child window is launched with a link in flash.

    thanks

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    In the future please post some code for us to work with.

    You can try:

    PHP Code:
    getURL("javascript: window.open('somepage.html','myWindow');","_self"); 
    That should assign an opener to your window.

  3. #3
    Senior Member
    Join Date
    Apr 2004
    Posts
    156
    hi I will try that thank you, my code is just a target blank window from the flash movie. and in the new window:

    Code:
    function swapWin(winLink) {
    	if (window.opener != null && !window.opener.closed) {
    		window.opener.location = winLink;
    		window.opener.focus();
    		}
    	else {
    		window.open(winLink, "newWindow");
    	}
    }
    and called with

    Code:
    <a href="javascript:swapWin('http://www.google.com/');">link to brand site</a>

  4. #4
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Using this javascript works for me:
    PHP Code:
    var myWindow;

    function 
    swapWin(winLink) {
        if (
    myWindow != null && !myWindow.closed) {
            
    myWindow.location winLink;
            
    myWindow.focus();
        }else{
            
    myWindow window.open(winLink"newWindow");
        }


  5. #5
    Senior Member
    Join Date
    Apr 2004
    Posts
    156
    ya doesnt look like that worked, popped up the new window but then changed the url of the parent too and didnt work in ie, thank you for the reply though.

  6. #6
    Senior Member
    Join Date
    Apr 2004
    Posts
    156
    yeah that code works in every browser but ie6/7

  7. #7

  8. #8
    Senior Member
    Join Date
    Apr 2004
    Posts
    156
    could I get a link?

    mine blocks the popup with the window open method but with popups allowed it works but redirects the parent to say [object window] thanks again.

  9. #9

  10. #10
    Senior Member
    Join Date
    Apr 2004
    Posts
    156
    hmm here is my button code something must be off but its early and im not seeing it

    Code:
    test.onRelease = function() {
    	getURL("javascript: window.open('index2.html','newWin');","_self"); 
    }

  11. #11
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    I am using my javascript function from above along with this code in flash:

    PHP Code:
    <a href="javascript:swapWin('http://www.google.com/');">link to brand site</a

  12. #12
    Senior Member
    Join Date
    Apr 2004
    Posts
    156
    thanks again for the help so far. i dont think i was totally clear with what i was doing but i was able to use what you did to make this work so thanks.

    1 more problem: the window.open function is getting trapped by a popup blocker in ie, is there a way to use the window.open function without having it stopped by a standard popup blocker?

    thanks

    heres the actionscript
    Code:
    test.onRelease = function() {
    	getURL("javascript:openContact();");
    }
    code for index landing page
    Code:
    <script type="text/javascript">
    window.onload = function() {
    	var myWindow;
    	var winLink;
    }
    function openContact() {
    		winLink = 'index2.html';
    		myWindow = window.open(winLink, "newWindow");
    }
    </script>
    code for the window.open index2.html page
    Code:
    <script type="text/javascript">
    function swapWin(winLink) {
    	if (window.opener != null && !window.opener.closed) {
    		window.opener.location = winLink;
    		window.opener.focus();
    		}
    	else {
    		window.open(winLink, "newWindow");
    	}
    }
    </script>
    
    and the html <a href="javascript:swapWin('http://www.google.com/');">link to brand site</a>
    once that link it clicked it changes the url of the parent and refocuses the parent on top.

    anyway popup blocker and window.open, any ideas?

  13. #13
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    There is no way around a popup blocker using the window.open method, you can however use a 'lightbox' script which will display a pseudo popup inside the same window your website is in.

    Google that, will get you started.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center