470,815 Members | 3,236 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,815 developers. It's quick & easy.

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

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
1 4539
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.

Similar topics

4 posts views Thread by Tom Szabo | last post: by
15 posts views Thread by Reid Nichol | last post: by
2 posts views Thread by flywave | last post: by
reply views Thread by candra | last post: by
2 posts views Thread by belred | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.