2012-10-18 63 views
1

我试图在访问者输入促销活动的访问代码后创建重定向。它适用于OS X Chrome & Safari和Windows Chrome,但不支持OS X Firefox或Windows IE & Firefox。JavaScript重定向表单在Chrome/Safari中,但也不是Firefox/IE

网站位于https://www.preciousmetals.com/offer12

我的头这个脚本...

<script type="text/javascript"> 
    function checkCode() { 
     if (this.password.value.toLowerCase() == 'AAL1012'.toLowerCase()) { 
      window.location='https://www.preciousmetals.com/special-offer-12.html'; 
     } 
     else { 
      alert('Wrong Access Code!'); 
     } 
     return false; 
    } 
    </script> 

而这在体内...

<form onsubmit="return checkCode()"> 
           <h3 style="text-align: center;"> 
            Enter Access Code To Proceed 
           </h3> 
           <div style="text-align: center;"> 
            <input type="password" id="password" /> 
            <input type="submit" value="Proceed" /> 
           </div> 
          </form> 

回答

1

你真的不能用来验证用JavaScript密码像那样。这是一个很大的安全问题。

如果你想这样做也无妨试试这个:

<h3 style="text-align: center;"> 
    Enter Access Code To Proceed 
</h3> 
<div style="text-align: center;"> 
    <input type="password" id="password" /> 
    <button onClick="checkCode();return false;" type="button">Proceed</button> 
</div> 

请注意,我去掉表格,取代了按钮的代码

+0

我知道,但真的有没有在这种使用情况下的安全系数。他们只是跟踪访问代码的广告系列响应。 这很好用!谢谢! –