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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Javascript callback in XML

    Hi,

    I have a Flash flip book that uses XML and has the ability to add JavaScript callback functions. I need my book to open up a pop-up window with a new URL. The new window needs to be a little smaller than the main window. I have tried this by using the following code in the XML file-
    link_callback="poptastic('http://www.google.com') a window opens but doesn't pop-up in front of the main window, rather (depending on the browser) it pops-up either behind the main window or in another tab. There is defiantly code that can do this- I have seen it done on a number of websites. Can anybody help me out with this?

    Thanks,
    Eric

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Show the code for the poptastic( ) function and we can help you. Maybe.

    Fundamentally, you open the window and then focus on it. Except *usually* when you open the window you automatically are focussed on it.

    The problem comes in that maybe some *other* code on your page is moving the focus to the main (opener) window.

    So a sneaky trick might be to add a timeout to the code that moves the focus *back* to the popup after half a second or so, hopefully after the code on the main page has finished changing the focus.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hi,

    Thanks for your reply.

    I will provide a link to the book so you will understand me better-
    http://jamanimations.com/WEB%28swf%29/index.html#/23
    The problem is when using IE and Chrome.

    Thanks for your help,
    Eric

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Does it EVER finish loading? Since you said IE and Chrome have problems, I'm trying to load it with FireFox.

    ... Still loading ...

    Okay...finally. Well, I see the function poptastic but I don't see any way to invoke it.

    What do I do to get the popup page you talked about?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    LOL! IT IS THE poptastic function ITSELF that is the problem!
    Code:
    function poptastic(url){
        window.open(url,'_blank');
        window.focus(); // Focus on the MAIN WINDOW!
    }
    After it opens the popup, it turns right around and says "but now put me back in front"!!!

    *PROBABLY* all you need to do is remove that line in red.

    If for some reason that doesn't do it:
    Code:
    var popup = null; // must be outside the function
    function poptastic(url){
        popup = window.open(url,'_blank');
        popup.focus(); // force focus to the new window
        setTimeout( "popup.focus()", 500 ); // just in case, do it again in half a second
    }
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    eric318 (08-02-2012)

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    By the by, EACH TIME the poptastic function is invoked, it will open a NEW popup.

    If that is not desired behavior, simply use a name for the window, instead of "_blank".

    Then each invocation of poptastic will reuse the same window.

    e.g.,
    Code:
        popup = window.open(url,"BOOK_POPUP");
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    It worked-thanks!
    Is there a way of resizing the pop-up window so it is smaller than the source window?

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    https://developer.mozilla.org/en/DOM/window.open

    Example:
    Code:
        window.open(url, "_blank", "width=800, height=600");
    But see all the other possible options in that documentation. When in doubt, Read The Fantastic Manual.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    eric318 (08-02-2012)

  • #9
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I am having now some problems with Chrome that i am not experiencing with Firefox and IE. The problem i am having is that when i hit the hyperlink that supposed to bring up my pop-up window, Chrome automatically blocks it. I cant understand why because i have my pop-ups blocked in the other 2 browsers also but they don't give me any problems. Do you have any insight?

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Different popup blockers are more or less sensitive. For example, in MSIE you *CAN* block 100% of *ALL* popups. Play with the popup blocker settings in your Chrome browser. See if there isn't a way, for example, to *NOT* block any popups from a given site.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    There is such a way of allowing pop-up windows for the site of your choosing, however my viewers may not know this and they may not even be aware that a window was supposed to pop-up but had been blocked.

    I found a site that the pop-up does not get blocked even when using Chrome-http://www.centrelink.gov.au/interne...home/index.htm Try clicking "Log on" on the right hand side and you will see for yourself.

  • #12
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Yes, because that is a link opened AS A DIRECT RESULT of HUMAN interaction.

    It's simply a <a href="..." target="_blank">...</a>

    Yours is *NOT* the result of HUMAN interaction. It is pure JS code doing it. Yours is indistinguishable--to the browser--from any advertising popup. (Heck, for all I know, yours might really be an advertising popup.) *COMPLETELY* different thing, from the browsers' perspectives.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • Users who have thanked Old Pedant for this post:

    eric318 (08-03-2012)

  • #13
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    would i be able to use this code in my book?

  • #14
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    I have no idea. I couldn't even FIND the code on your book page when I looked at it.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #15
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    My flash uses XML that contains the ability to insert JavaScript call-back functions.
    I have attached the XML code. The pop-up script is on line 209.
    Thanks.
    Attached Files Attached Files


  •  
    Page 1 of 2 12 LastLast

    Tags for this Thread

    Posting Permissions

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