how-to reload variable value in page when external js file changed

Z

zdhiu

Hi javascript gurus,
I have a simple html file (simple.html) with
javascript. In html page there is sentence from
variable defined in .js file (myFirst.js). Once I
reload another .js file (mySecond.js), the value
defined in the second one is NOT reloaded into html
page.
Please help out what's wrong in my code.
BTW, I use IE6.0

Many thanks!

Code in simple.html
--------------
<html>
<head>
<script language='javascript' type='text/javascript' id='myScript' src='myFirst.js'>
</script>
<script language='javascript' type='text/javascript'>
function reload(order){
mySrc = "my"+order+".js"
document.getElementById('myScript').src = mySrc
alert("Your order: "+order+" and my SRC: "+mySrc+" and "+great)
}
reload("First")
</script>
</head>
<body>
<script language='javascript' type='text/javascript'>
document.write(great)
</script>
<form>
<p>Reload greating:
<input type="button" value="Reload, please!"
onclick='reload("Second")'></p>
</form>
</body>
</html>

myFirst.js
 
Z

zdhiu

Hi javascript gurus,
I have a simple html file (simple.html) with
javascript. In html page there is sentence from
variable defined in .js file (myFirst.js). Once I
reload another .js file (mySecond.js), the value
defined in the second one is NOT reloaded into html
page.
Please help out what's wrong in my code.
BTW, I use IE6.0

Many thanks!

Code in simple.html
--------------
<html>
<head>
<script language='javascript' type='text/javascript' id='myScript' src='myFirst.js'>
</script>
<script language='javascript' type='text/javascript'>
function reload(order){
mySrc = "my"+order+".js"
document.getElementById('myScript').src = mySrc
alert("Your order: "+order+" and my SRC: "+mySrc+" and "+great)
}
reload("First")
</script>
</head>
<body>
<script language='javascript' type='text/javascript'>
document.write(great)
</script>
<form>
<p>Reload greating:
<input type="button" value="Reload, please!"
onclick='reload("Second")'></p>
</form>
</body>
</html>

myFirst.js
----------
var great="First Greeting: Hello Internet!"

mySecond.js
-----------
var great="The Second Greeting: Hello Internet!"


zdhiu

It seems that my bad description in this post; or nobody has this
problem | don't know this problem here.

Anyway, I got solution and fix it.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top