passing variables?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George Hester

    passing variables?

    I have a statement such as this:

    <body onmousedown="Ja vaScript:var x = :xlocCur();">

    This xlocCur returns a number, integer.

    then in the body I have:

    <script type="text/javascript">
    alert(x)
    </script>

    x is undefined. How can I pass values between JavaScript islands?

    --
    George Hester
    _______________ _______________ ____
  • Michael Winter

    #2
    Re: passing variables?

    George Hester wrote on 05 Dec 2003:
    [color=blue]
    > I have a statement such as this:
    >
    > <body onmousedown="Ja vaScript:var x = :xlocCur();">[/color]

    "JavaScript :" above is supposed to be used as a URI specifier, not to
    determine the language of intrinsic events. To do this, declare the
    default scripting language with the following META element placed in
    the document head:

    <META http-equiv="Content-Script-Type" content="text/javascript">

    The above intrinsic event can (and /should/) be written as:

    <BODY onmousedown="va r x = xlocCur()">
    [color=blue]
    > This xlocCur returns a number, integer.
    >
    > then in the body I have:
    >
    > <script type="text/javascript">
    > alert(x)[/color]

    You should qualify that call properly (window.alert).
    [color=blue]
    > </script>
    >
    > x is undefined. How can I pass values between JavaScript islands?[/color]

    Three options:

    1) Don't define the variable with the var keyword. That should place
    it in global, rather than local, scope.

    2) Define the variable (with or without var) in a script block
    outside of a function (so it becomes global). Then simply assign to
    it as normal.

    3) Use a function for the intrinsic event.

    function myEventHandler( ) {
    window.alert( xlocCur() );
    }

    Mike

    --
    Michael Winter
    M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk")

    Comment

    • George Hester

      #3
      Re: passing variables?

      Hmm thanks Michael. I found a way around it:

      <a onmousedown="Ja vaScript:var x = :xlocCur(); function(x);">

      But I like yours better.

      --
      George Hester
      _______________ _______________ ____
      "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message news:Xns94486ED 303292MWinterBl ueyonder@193.38 .113.46...[color=blue]
      > George Hester wrote on 05 Dec 2003:
      > [color=green]
      > > I have a statement such as this:
      > >
      > > <body onmousedown="Ja vaScript:var x = :xlocCur();">[/color]
      >
      > "JavaScript :" above is supposed to be used as a URI specifier, not to
      > determine the language of intrinsic events. To do this, declare the
      > default scripting language with the following META element placed in
      > the document head:
      >
      > <META http-equiv="Content-Script-Type" content="text/javascript">
      >
      > The above intrinsic event can (and /should/) be written as:
      >
      > <BODY onmousedown="va r x = xlocCur()">
      > [color=green]
      > > This xlocCur returns a number, integer.
      > >
      > > then in the body I have:
      > >
      > > <script type="text/javascript">
      > > alert(x)[/color]
      >
      > You should qualify that call properly (window.alert).
      > [color=green]
      > > </script>
      > >
      > > x is undefined. How can I pass values between JavaScript islands?[/color]
      >
      > Three options:
      >
      > 1) Don't define the variable with the var keyword. That should place
      > it in global, rather than local, scope.
      >
      > 2) Define the variable (with or without var) in a script block
      > outside of a function (so it becomes global). Then simply assign to
      > it as normal.
      >
      > 3) Use a function for the intrinsic event.
      >
      > function myEventHandler( ) {
      > window.alert( xlocCur() );
      > }
      >
      > Mike
      >
      > --
      > Michael Winter
      > M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk")[/color]

      Comment

      Working...