【问题标题】:prototype 1.7 is not working with Chrome and IE原型 1.7 不适用于 Chrome 和 IE
【发布时间】:2014-09-21 23:50:08
【问题描述】:

我正在尝试使用原型脚本构建一个带有交互式界面的登录页面,但我在 chrome 和 IE 中发现了一些问题,在 FireFox 中做得很好,我不知道为什么。

这里是 index.php 的代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//AR" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Take Surveys and Get Cash</title>
<script type='text/javascript' src="prototype-1.7.1.js"></script>
<script type='text/javascript'>
function refresh()
{
   var opt = {
                method: 'get', 
                parameters: '',
             };
   var url = 'page2.php';
   var laRequete = new Ajax.Updater('conteneur', url, opt);
}
</script>
<style type="text/css">
<!--
#conteneur {
    background-color:White;
    margin:auto;
    width:800px;
}
.Style1 {
    color: YELLOW;
    font-weight: bold;
    font-size: 36px;
}
.Style3 {
    color: WHITE;
    font-weight: bold;
    font-size: 36px;
}
#body {
    background-color:White;
}
#maj{
    cursor:pointer;
}
.Style2 {font-size: larger}
-->
</style>

</head>

<body>

<div id="conteneur">
    <table BORDER="0">
        <tr>
            <td COLSPAN="2"><img src="survey.png" /></td>
        </tr>
        <tr>
            <td><span id='maj' onclick="refresh();"><img src="Yes.png" /></span></td>
            <td><span id='maj' onclick="refresh();"><img src="No.png" /></span></td>
        </tr>
    </table>

<div id="statcounter_image" style="display:inline;"><a
title="hits counter" href="http://statcounter.com/"
class="statcounter"><img
src="http://c.statcounter.com/9318376/0/c82ce179/1/"
alt="hits counter" style="border:none;" /></a></div>
</div>
</body>
</html>

这是 page2.php 中的代码:

<table BORDER="0">
    <tr>
        <td COLSPAN="2"><img src="Age.png" /></td>
    </tr>
    <tr>
        <td><span id='maj' onclick="refresh();"><img src="Yes.png" /></span></td>
        <td><span id='maj' onclick="refresh();"><img src="No.png" /></span></td>
    </tr>
</table>

【问题讨论】:

    标签: php internet-explorer google-chrome prototypejs prototype


    【解决方案1】:

    您的脚本存在一些问题,可能会导致其无法正常工作

    1. 您在 2 个不同的元素 (maj) 上注册了相同的 id,该页面的 id 应该是唯一的

    2. 您正在使用 onclick 属性而不是事件观察者,请尝试使用像这样的观察者$('maj').observe('click',refresh)

    3. 更新到 2014 年 4 月发布的最新版 PrototypeJS (1.7.2),有很多错误和更新已在最新版本中修复。

    【讨论】:

      猜你喜欢
      • 2015-06-21
      • 2016-08-09
      • 2012-01-27
      • 2012-02-14
      • 2013-07-09
      • 2015-05-07
      • 1970-01-01
      • 2013-04-22
      • 2016-01-29
      相关资源
      最近更新 更多