Loading ...
Sorry, an error occurred while loading the content.

How does a Loaded script use global variables?

Expand Messages
  • deltareum
    I have a global variable in my HTML page, like so: var foobar=false;
    Message 1 of 2 , Dec 27, 2008
    • 0 Attachment
      I have a global variable in my HTML page, like so:

      <script type="text/javascript" src="com.iskitz.ajile.js"></script>
      <script>
      var foobar=false;
      </script>

      Later, I load an additional script that needs to modify this variable
      foobar. How does the external script access it? Plainly referring to
      its name, foobar=true; , as embedded scripts would do, does not work.

      Thanks.
    • mikeizworkin
      Hi, Ajile doesn t try to change any variables you define, so the problem you ve described is probably due to something else in your script setup. A few
      Message 2 of 2 , Dec 29, 2008
      • 0 Attachment
        Hi,
        Ajile doesn't try to change any variables you define, so the problem
        you've described is probably due to something else in your script setup.

        A few comments:

        1. What do you mean by "foobar=true...does not work"? Are you saying
        that an error is thrown when you try to set foobar to true or that
        foobar always remains set to false?

        2. Remove Ajile from the picture and try manually loading your scripts
        in the order you've described. After doing this does the same problem
        still exist?

        3. If possible provide a complete sample that demonstrates the problem
        you're seeing and state in which browser(s) you see the problem.


        Thanks,
        Mike

        --- In ajile@yahoogroups.com, "deltareum" <deltareum@...> wrote:
        >
        > I have a global variable in my HTML page, like so:
        >
        > <script type="text/javascript" src="com.iskitz.ajile.js"></script>
        > <script>
        > var foobar=false;
        > </script>
        >
        > Later, I load an additional script that needs to modify this variable
        > foobar. How does the external script access it? Plainly referring to
        > its name, foobar=true; , as embedded scripts would do, does not work.
        >
        > Thanks.
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.