JS problem

M

Micha³ J.

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

<script language='javascript' 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='javascript>
a=<script ... src='xxx.js'></script>;
a*=20;
document.write(a);
</script>

Please help me.
 
V

VK

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.glbInteger = someValue;
document,write(someValue);
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top