Need help converting 'onclick' script to 'href' script...

Discussion in 'Javascript' started by whitgurley@gmail.com, Dec 26, 2006.

  1. Guest

    I've searched the web as well as I can for a solution to this problem
    but have found nothing and just don't know enough about JavaScript to
    figure out what's going. What I'm trying to do is convert this script:

    <a href="#"
    onclick="MM_goToURL('parent.frames[\'movieA\']','color2.html');return
    document.MM_returnValue">TEST</a>

    ....to something that I can use within a Flash movie, which as far as I
    can tell means that it needs to reside in the 'href' (GetURL) attribute
    instead of a separate 'onclick' event. I've tried to do this with this
    test version:

    <a
    href="javascript:MM_goToURL('parent.frames[\'movieA\']','color2.html');return
    document.MM_returnValue">TEST2</a>

    ....which seems to be working in Firefox/Mac, but nowhere else (IE and
    Safari are the only other browsers I really care about). I'm hoping
    that you JS pros will know immediately what the problem is here (other
    than the author not knowing what he's doing). Thanks in advance to
    anyone who can help.

    In case anyone is interested, I'm attempting to setup a Flash-based
    portfolio site that displays loaded-on-the-fly content in pop-up
    iFrames above the movie (*that* much I've figured out). The script
    above references this Macromedia script:

    <script type="text/JavaScript">
    <!--
    function MM_goToURL() { //v3.0
    var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    for (i=0; i<(args.length-1); i+=2)
    eval(args+".location='"+args[i+1]+"'");
    }
    //-->
    </script>

    The only technical hitch I have now is getting this script to do the
    popping.

    Thanks!
    - whit
    , Dec 26, 2006
    #1
    1. Advertising

  2. dalouis Guest

    I know that in IE you can do this but its very picky and if you do it
    the wrong way it either gives you a blank page or an error. I know for
    a fact that I have something like the following code working in IE 5
    and above:

    <a href="javascript:parent.doSomething('5273')";>

    The only real difference between mine and yours is that you have more
    than one statement inside the javascript: part. I would recommend
    trying to do the same thing except put the return statement inside your
    function instead of inline in the javascript: command.

    ie try it without the "return
    > document.MM_returnValue" inside your <a > tag.


    Oh and looking at it again I know that having " " and ' ' begins to
    cause problems in this particular href=javascript notation. I have had
    many problems with it in the past. If the above doesnt work I would
    recommend remove the escape characters \' as these may be confusing
    it. If you can , handle the escape character inside the actual
    function.

    the simpler that href=javascript command is , the easier it will be
    for you to debug, of this im sure. Try to do as much as you can inside
    the function.


    wrote:
    > I've searched the web as well as I can for a solution to this problem
    > but have found nothing and just don't know enough about JavaScript to
    > figure out what's going. What I'm trying to do is convert this script:
    >
    > <a href="#"
    > onclick="MM_goToURL('parent.frames[\'movieA\']','color2.html');return
    > document.MM_returnValue">TEST</a>
    >
    > ...to something that I can use within a Flash movie, which as far as I
    > can tell means that it needs to reside in the 'href' (GetURL) attribute
    > instead of a separate 'onclick' event. I've tried to do this with this
    > test version:
    >
    > <a
    > href="javascript:MM_goToURL('parent.frames[\'movieA\']','color2.html');return
    > document.MM_returnValue">TEST2</a>
    >
    > ...which seems to be working in Firefox/Mac, but nowhere else (IE and
    > Safari are the only other browsers I really care about). I'm hoping
    > that you JS pros will know immediately what the problem is here (other
    > than the author not knowing what he's doing). Thanks in advance to
    > anyone who can help.
    >
    > In case anyone is interested, I'm attempting to setup a Flash-based
    > portfolio site that displays loaded-on-the-fly content in pop-up
    > iFrames above the movie (*that* much I've figured out). The script
    > above references this Macromedia script:
    >
    > <script type="text/JavaScript">
    > <!--
    > function MM_goToURL() { //v3.0
    > var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    > for (i=0; i<(args.length-1); i+=2)
    > eval(args+".location='"+args[i+1]+"'");
    > }
    > //-->
    > </script>
    >
    > The only technical hitch I have now is getting this script to do the
    > popping.
    >
    > Thanks!
    > - whit
    dalouis, Dec 26, 2006
    #2
    1. Advertising

  3. Guest

    Thanks a lot for the reply, dalouis. I've done a little tinkering and
    am still not have having any real luck. My revised setup is this:

    <script type="text/JavaScript">
    <!--
    function MM_goToURL() { //v3.0
    var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    for (i=0; i<(args.length-1); i+=2)
    eval(args+".location='"+args[i+1]+"'");
    return true
    }
    //-->
    </script>

    <a
    href="javascript:MM_goToURL('parent.frames[\'movieA\']','color2.html')">TEST2</a>

    This setup is still working fine in Safari (I had my browser details
    wrong in the original message), but in Firefox it's causing the link to
    bounce me to a page that just says "false" (you probably could have
    told me that by looking at the function). I tried removing the escapes
    outright, which broke the setup completely, but I re-read the reply and
    realized you meant for me to move them up to the function. Problem is,
    I don't have any idea where or how to do that. Any more tips?


    dalouis wrote:
    > I know that in IE you can do this but its very picky and if you do it
    > the wrong way it either gives you a blank page or an error. I know for
    > a fact that I have something like the following code working in IE 5
    > and above:
    >
    > <a href="javascript:parent.doSomething('5273')";>
    >
    > The only real difference between mine and yours is that you have more
    > than one statement inside the javascript: part. I would recommend
    > trying to do the same thing except put the return statement inside your
    > function instead of inline in the javascript: command.
    >
    > ie try it without the "return
    > > document.MM_returnValue" inside your <a > tag.

    >
    > Oh and looking at it again I know that having " " and ' ' begins to
    > cause problems in this particular href=javascript notation. I have had
    > many problems with it in the past. If the above doesnt work I would
    > recommend remove the escape characters \' as these may be confusing
    > it. If you can , handle the escape character inside the actual
    > function.
    >
    > the simpler that href=javascript command is , the easier it will be
    > for you to debug, of this im sure. Try to do as much as you can inside
    > the function.
    >
    >
    > wrote:
    > > I've searched the web as well as I can for a solution to this problem
    > > but have found nothing and just don't know enough about JavaScript to
    > > figure out what's going. What I'm trying to do is convert this script:
    > >
    > > <a href="#"
    > > onclick="MM_goToURL('parent.frames[\'movieA\']','color2.html');return
    > > document.MM_returnValue">TEST</a>
    > >
    > > ...to something that I can use within a Flash movie, which as far as I
    > > can tell means that it needs to reside in the 'href' (GetURL) attribute
    > > instead of a separate 'onclick' event. I've tried to do this with this
    > > test version:
    > >
    > > <a
    > > href="javascript:MM_goToURL('parent.frames[\'movieA\']','color2.html');return
    > > document.MM_returnValue">TEST2</a>
    > >
    > > ...which seems to be working in Firefox/Mac, but nowhere else (IE and
    > > Safari are the only other browsers I really care about). I'm hoping
    > > that you JS pros will know immediately what the problem is here (other
    > > than the author not knowing what he's doing). Thanks in advance to
    > > anyone who can help.
    > >
    > > In case anyone is interested, I'm attempting to setup a Flash-based
    > > portfolio site that displays loaded-on-the-fly content in pop-up
    > > iFrames above the movie (*that* much I've figured out). The script
    > > above references this Macromedia script:
    > >
    > > <script type="text/JavaScript">
    > > <!--
    > > function MM_goToURL() { //v3.0
    > > var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
    > > for (i=0; i<(args.length-1); i+=2)
    > > eval(args+".location='"+args[i+1]+"'");
    > > }
    > > //-->
    > > </script>
    > >
    > > The only technical hitch I have now is getting this script to do the
    > > popping.
    > >
    > > Thanks!
    > > - whit
    , Dec 27, 2006
    #3
  4. Guest

    Doesn't look like "bumping" works in newsgroups like this, but I'll try
    it anyway. Anybody out there who can shed some light on this issue?
    , Dec 30, 2006
    #4
  5. VK Guest

    wrote:
    > Doesn't look like "bumping" works in newsgroups like this, but I'll try
    > it anyway. Anybody out there who can shed some light on this issue?


    You cannot do it on modern browsers with the default Flash player
    installation.
    javascript:void(codeToExecute) pseudo-protocol trick was good for a
    long time but now it's blocked as well.

    On IE 6,7 it's simply ignored, on Firefox you'll see a security warning
    dialog. It is because the modern Flash player is a sophisticated
    programming environment by its own with security policies differing
    sometimes from the policies of the browser it is run on (XMLHttpRequest
    cross-domain communication is the first comming into my mind).
    Respectively it may have his very own security exploits which browser
    producers do not want to be held responsible for.

    This way either abandon Flash whatsoever or make the entire interface
    as one big Flash movie.
    VK, Dec 30, 2006
    #5
  6. Guest

    Crap. That screws up my plan. I really don't want to enclose the entire
    thing in a Flash movie. No wonder the existing setup wasn't working in
    any browser that I was testing it in. Still, how is that different from
    issuing JS pop-up window commands? The pop-up contact form at this site
    still works:
    http://www.morris-day.com/home.html (click "Contact Us" then the
    "Contact Form" link)

    I can make my plan work with actual pop-up windows, I'd just prefer to
    use DIVs. At any rate, thanks for the reply, VK.


    VK wrote:
    > You cannot do it on modern browsers with the default Flash player
    > installation.
    > javascript:void(codeToExecute) pseudo-protocol trick was good for a
    > long time but now it's blocked as well.
    >
    > On IE 6,7 it's simply ignored, on Firefox you'll see a security warning
    > dialog. It is because the modern Flash player is a sophisticated
    > programming environment by its own with security policies differing
    > sometimes from the policies of the browser it is run on (XMLHttpRequest
    > cross-domain communication is the first comming into my mind).
    > Respectively it may have his very own security exploits which browser
    > producers do not want to be held responsible for.
    >
    > This way either abandon Flash whatsoever or make the entire interface
    > as one big Flash movie.
    , Dec 30, 2006
    #6
  7. VK Guest

    wrote:
    >. Still, how is that different from
    > issuing JS pop-up window commands? The pop-up contact form at this site
    > still works:
    > http://www.morris-day.com/home.html (click "Contact Us" then the
    > "Contact Form" link)


    Difficult to say - as I said Flash ActionScript may have its own
    vulnerabilities and respectively its own bug exploits. From the other
    side I see address bar flashing for a sec in the new window but
    disappearing after. So maybe they simply do getURL(formPage) with
    _target blank - so no javascript usage from movie, pure HTML mechanics,
    and the script on formPage does the rest.

    I don't want to decompile someone's movie without permission, so I
    cannot tell for sure.

    See also
    <http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager.html#117164>
    VK, Dec 30, 2006
    #7
  8. Guest

    I should have specified that I created it - years ago, so I didn't
    remember what the setup was - and also didn't realize I had the source
    file handy. It looks like you're half right:
    on (release) {
    getURL("javascript:eek:penNewWindow('contact.html','contact','height=700,width=800,toolbar,scrollbars,resizable,left=20,top=20')");
    }

    All the parameters seem to be contained in the one "URL," so I guess
    this is allowed because it's not calling a function elsewhere on the
    page?


    VK wrote:
    > Difficult to say - as I said Flash ActionScript may have its own
    > vulnerabilities and respectively its own bug exploits. From the other
    > side I see address bar flashing for a sec in the new window but
    > disappearing after. So maybe they simply do getURL(formPage) with
    > _target blank - so no javascript usage from movie, pure HTML mechanics,
    > and the script on formPage does the rest.
    >
    > I don't want to decompile someone's movie without permission, so I
    > cannot tell for sure.
    >
    > See also
    > <http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager.html#117164>
    , Dec 30, 2006
    #8
  9. VK Guest

    wrote:
    > I should have specified that I created it - years ago, so I didn't
    > remember what the setup was - and also didn't realize I had the source
    > file handy. It looks like you're half right:
    > on (release) {
    > getURL("javascript:eek:penNewWindow('contact.html','contact','height=700,width=800,toolbar,scrollbars,resizable,left=20,top=20')");
    > }
    >
    > All the parameters seem to be contained in the one "URL," so I guess
    > this is allowed because it's not calling a function elsewhere on the
    > page?


    That is a fancy matter. On my Firefox 1.5 / Flash 9.0 plugin for your
    side I'm indeed getting popup window. At the same time even for a
    _local_ page having openNewWindow function called from flash by
    getURL("javascript:eek:penNewWindow()") I'm getting security alert.

    I'm admittedly not a profound specialist of Flash <> JavaScript
    bridging, maybe it's time for a more specific group like
    <macromedia.flash.actionscript>. Some answer can be also hidden at
    <http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html#119065>

    If you come up with an explanation, it would be hice to have it posted
    here.
    VK, Dec 30, 2006
    #9
  10. Guest

    I'll open up a conversation on that group and let you know if the
    question gets answered. Thanks for your feedback, VK.


    VK wrote:
    > wrote:
    > > I should have specified that I created it - years ago, so I didn't
    > > remember what the setup was - and also didn't realize I had the source
    > > file handy. It looks like you're half right:
    > > on (release) {
    > > getURL("javascript:eek:penNewWindow('contact.html','contact','height=700,width=800,toolbar,scrollbars,resizable,left=20,top=20')");
    > > }
    > >
    > > All the parameters seem to be contained in the one "URL," so I guess
    > > this is allowed because it's not calling a function elsewhere on the
    > > page?
    , Dec 30, 2006
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CRON
    Replies:
    24
    Views:
    200,474
    Adrienne Boswell
    Jun 20, 2006
  2. Soren Vejrum
    Replies:
    4
    Views:
    532
    Lasse Reichstein Nielsen
    Jul 5, 2003
  3. Replies:
    2
    Views:
    445
  4. Jerry Sievers
    Replies:
    4
    Views:
    155
    Jerry Sievers
    Jul 31, 2005
  5. Vincent van Beveren

    BASE HREF and A HREF="#" onclick="..."

    Vincent van Beveren, Jul 6, 2006, in forum: Javascript
    Replies:
    2
    Views:
    297
    Vincent van Beveren
    Jul 6, 2006
Loading...

Share This Page