prototype 1.7不支持Chrome和IE


prototype 1.7 is not working with Chrome and IE

我正在尝试使用原型脚本建立一个带有交互界面的登陆页面,但我在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>

你的脚本有几个问题可能会阻止它正常工作

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

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

  3. 更新到2014年4月发布的最新版本PrototypeJS(1.7.2),最新版本修复了许多错误和更新。