在不同的HTML文件中访问JAVASCRIPT中声明的变量 [英] Accesing variables declared in JAVASCRIPT in a different HTML FILE
本文介绍了在不同的HTML文件中访问JAVASCRIPT中声明的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个文件screen.html和db_fun.js。
我刚刚在开头声明了一个变量,如下所示:
I have two files screen.html and db_fun.js.
I have declared a variable at just the beginning as follows:
db_fun.js
var name =abc;
now i试图访问screen.html文件中的这个变量,如下所示:
now i tried to access this variable in the screen.html file as follows
screen.html
<html>
<body>
<form name = "screen" action = "db_fun.js">
<p> <script>document.write(name);</script> </p>
</form>
</body>
<script src="db_fun.js" type="text/javascript" />
</html>
它不打印nethn。是这样吗?
it doesn't print nethn. Y so?
推荐答案
将此添加到头部
<script type="text/javascript" src="db_fun.js"></script>
这篇关于在不同的HTML文件中访问JAVASCRIPT中声明的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文