[英]JavaScript Undefined Variable Error In IE6
I have a PHP file in that I have declared a JavaScript variable. 我有一个PHP文件,我已经声明了一个JavaScript变量。
I will get that variable value while I am opening the page directly by type the my URL on IE6. 当我通过在IE6上键入我的URL直接打开页面时,我将获得该变量值。
But the problem is if I am clicking a href
link to open the same page got particular variable undefined error on IE6. 但问题是如果我点击一个
href
链接打开同一页面得到IE6上的特定变量未定义错误。
After undefined error if I refresh the same page I can get the variable value. 在未定义的错误之后,如果我刷新同一页面,我可以得到变量值。
I am using script tag to load the page 我正在使用脚本标记来加载页面
as like 就像
<script language="javascript" src="commonjs.php"></script>
In my commonjs.php 在我的commonjs.php中
<? include_once("myconffile.php"); ?>
var myvars = <?=$varConfValue['domainname']?>
Please help me on this. 请帮帮我。
You should add quotes around the value of myvars
if it is a string. 如果它是一个字符串,你应该在
myvars
的值周围添加引号。
<? include_once("myconffile.php"); ?>
var myvars = "<?=$varConfValue['domainname']?>"
Otherwise you get something like var myvars = localhost
. 否则你会得到类似
var myvars = localhost
东西。 Javascript then looks for a variable named localhost
, which is undefined. 然后Javascript查找名为
localhost
的变量,该变量未定义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.