[英]Javascript not loading on one page, works fine on another
I have the following piece of javascript on one of my pages 我的其中一个页面上有以下javascript代码
<script type="text/javascript">
var state = 'none';
function showhide(layer_ref, badgeid, location) {
alert("Run")
if (state == 'block') {
state = 'none';
}
else
{
state = 'block';
}
hza = document.getElementById(layer_ref);
hza.style.display = state;
if (state == 'block') {
badgeinfo(badgeid, location);
}
}
</script>
its called using 它称为
<td width="50%" align="right" valign="middle" onclick="showhide('id215', '215', 'req_215');"><img src="/images/badges/2015be-cs-csa.png" width="100" height="100" alt="Chief Scout's Bronze Award" /></td>
One on page its loads fine, i get the alert when i click the image, but on another page, nothing happens, the alert isn't shown. 在一页上加载效果很好,当我单击该图像时会收到警报,但是在另一页上却什么也没有发生,因此不会显示该警报。
The page is dynamically produced based on a couple of variables which define what section is loaded. 该页面是基于几个变量的动态生成的,这些变量定义了加载哪个部分。 Even if i change the javascript function to just the alert it doesn't do anything.
即使我将javascript函数更改为警报,它也不会执行任何操作。 If i change the section of the badges in the database so they load on another page its fine, and previously working badges if they are on this section don't load
如果我更改了数据库中的徽章部分,以便它们可以很好地加载到另一页上,并且以前在此部分中工作的徽章也不会加载
This is the non working page http://new.wgcscouts.co.uk/test1.php 这是非工作页面http://new.wgcscouts.co.uk/test1.php
And this is a working one http://new.wgcscouts.co.uk/test2.php 这是一个有效的http://new.wgcscouts.co.uk/test2.php
In the working example, there is an index number appended to the section url... 在工作示例中,在部分url后面附加了一个索引号...
url=url+"&section="+1;
The number at the end of line 51 is not being populated in the non-working example 在非工作示例中,不会填充第51行末尾的数字
url=url+"&section="+;
That is a syntax error for javascript, which then stops executing as it can't parse the input. 这是javascript的语法错误,由于无法解析输入内容,因此该脚本停止执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.