wOlVeRiNe wOlVeRiNe - 1 year ago 60
HTML Question

Accesing variables declared in JAVASCRIPT in a different HTML FILE

I have two files screen.html and db_fun.js.
I have declared a variable at just the beginning as follows:


var name = "abc";

now i tried to access this variable in the screen.html file as follows


<form name = "screen" action = "db_fun.js">
<p> <script>document.write(name);</script> </p>
<script src="db_fun.js" type="text/javascript" />

it doesn't print nethn. Y so?

Answer Source

add this to the head

<script type="text/javascript" src="db_fun.js"></script>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download