JS problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Micha³ J.

    #1

    JS problem

    First script, 'xxx.js' returns value 'document.write ('integer');
    So in HTML:

    <script language='javas cript' src='xxx.js'></script>

    will write ie. 123 on my page in browser.

    Can I get this integer or text 'document.write ('integer')' to variable in
    another script? So it would be something like this:

    <script landuage='javas cript>
    a=<script ... src='xxx.js'></script>;
    a*=20;
    document.write( a);
    </script>

    Please help me.

    --
    Mike J.
    mike_j@o2.pl



  • VK

    #2
    Re: JS problem

    Not directly like in C++ (JavaScript doesn't support references
    explisitly).
    Plus the script by itself doesn't return any values. Functions in the
    script do.
    So whatever function does document.write( ), you can:

    1. Assign "integer" value to a global variable in your xxx.js
    var glbInteger = null;
    function write2doc (someValue) {
    glbInteger = someValue;
    document.write( someValue);
    }
    2. Add a property to any global object
    self.document.g lbInteger = someValue;
    document,write( someValue);

    Micha³ J. <mike_j@o2.pl > wrote in message
    news:JsOib.1014 0$Lo.156707@new s.chello.at...[color=blue]
    > First script, 'xxx.js' returns value 'document.write ('integer');
    > So in HTML:
    >
    > <script language='javas cript' src='xxx.js'></script>
    >
    > will write ie. 123 on my page in browser.
    >
    > Can I get this integer or text 'document.write ('integer')' to variable[/color]
    in[color=blue]
    > another script? So it would be something like this:
    >
    > <script landuage='javas cript>
    > a=<script ... src='xxx.js'></script>;
    > a*=20;
    > document.write( a);
    > </script>
    >
    > Please help me.
    >
    > --
    > Mike J.
    > mike_j@o2.pl
    >
    >
    >[/color]


    Comment

    Working...