REPOST: Macormedia Javascript function in PocketIE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James Leech

    REPOST: Macormedia Javascript function in PocketIE

    Reposted due to no response.

    Hi guys

    I am using Dreamweaver to create an intranet site that is to be accessed by
    a PDA, but I have hit a problem with JavaScript under Pocket Internet
    Explorer. I have added a standard DW behaviour (function to non-DW peeps)
    that simply redirects the user to another page and is fired when a user hits
    a button, but PocketIE seems to do nothing with it. I don't receive an error
    message, line number or anything! Any help on finding / fixing the problem
    would be gratefully appreciated - not being a JavaScript(let alone js on a
    pda) person, I don't.know where to start.

    Here's the code:

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

    Regards
    James
    tgl



  • RobG

    #2
    Re: REPOST: Macormedia Javascript function in PocketIE

    James Leech wrote:[color=blue]
    > Reposted due to no response.
    >
    > Hi guys
    >
    > I am using Dreamweaver to create an intranet site that is to be[/color]
    accessed by[color=blue]
    > a PDA, but I have hit a problem with JavaScript under Pocket Internet
    > Explorer. I have added a standard DW behaviour (function to non-DW[/color]
    peeps)[color=blue]
    > that simply redirects the user to another page and is fired when a[/color]
    user hits[color=blue]
    > a button, but PocketIE seems to do nothing with it. I don't receive[/color]
    an error[color=blue]
    > message, line number or anything! Any help on finding / fixing the[/color]
    problem[color=blue]
    > would be gratefully appreciated - not being a JavaScript(let alone js[/color]
    on a[color=blue]
    > pda) person, I don't.know where to start.
    >
    > Here's the code:
    >
    > <script language="JavaS cript" type="text/JavaScript">
    > <!--
    > function MM_goToURL() { //v3.0
    > var i, args=MM_goToURL .arguments; document.MM_ret urnValue = false;
    > for (i=0; i<(args.length-1); i+=2)
    > eval(args[i]+".location='"+ args[i+1]+"'");[/color]


    Does this code work in *any* browser? It appears to be something of
    an
    abomination! Maybe it makes more sense if you'd posted whatever the
    arguments are.

    If all you want to do is click on a button and go somewhere, and you
    apparently don't want to use a normal <a href="">, why not:

    <form action="">
    <button onclick="
    document.locati on='http://www.news.com'
    ">Go to news.com</button>
    </form>

    Or is simplicity dead?

    --
    Rob

    Comment

    • Michael Winter

      #3
      Re: REPOST: Macormedia Javascript function in PocketIE

      On Wed, 22 Dec 2004 11:59:06 -0000, James Leech
      <james@graphi cs-line.co.uk> wrote:

      [snip]
      [color=blue]
      > I have added a standard DW behaviour (function to non-DW peeps)[/color]

      All the code I've seen generated by DW is, quite frankly, crap. The code
      you've posted is no exception.
      [color=blue]
      > that simply redirects the user to another page[/color]

      Javascript should never be used for navigation, but as you're authoring
      for an intranet, you can probably get away with it.
      [color=blue]
      > and is fired when a user hits a button,[/color]

      Any reason why you can't just use a link? You're obviously going to have
      much better luck using standard functionality.

      [snip]
      [color=blue]
      > <script language="JavaS cript" type="text/JavaScript">[/color]

      [Unrelated] The language attribute is deprecated (has been for over six
      years) and redundant when the (required) type attribute is present.
      [color=blue]
      > <!--[/color]

      [Unrelated] Hiding scripts is also an out-dated practice.
      [color=blue]
      > function MM_goToURL() { //v3.0
      > var i, args=MM_goToURL .arguments;
      > document.MM_ret urnValue = false;
      > for (i=0; i<(args.length-1); i+=2)
      > eval(args[i]+".location='"+ args[i+1]+"'");[/color]

      It's possible that the eval function is unimplemented. ECMA-327, which
      defines a subset of ECMAScript, allows implementations to omit a few
      features to reduce load on the environment. However, as I don't have
      access to PocketIE I couldn't say for certain.

      If you're just altering the URL for the current document, you could
      simplify the function to

      function goToURL(url) {location.href = url;}

      If you're using frames (and you generally shouldn't):

      function goToURL(url, frame) {
      (frame || window).locatio n.href = url;
      }

      If the frame argument is omitted, the current document will be altered.

      If you really need the functionality provided by DW's original function:

      function goToURL() {
      for(var i = 0, n = arguments.lengt h; i < n; i += 2) {
      arguments[i].location.href = arguments[i + 1];
      }
      }

      As you can see, eval is entirely unnecessary. The author's just clueless.

      Hope that helps,
      Mike

      --
      Michael Winter
      Replace ".invalid" with ".uk" to reply by e-mail.

      Comment

      Working...