By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,536 Members | 1,800 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,536 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
zd***@yahoo.com (zdhiu) wrote in message news:<ea**************************@posting.google. com>...
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.
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.