简体   繁体   English

javascript重定向表单可以在Chrome / Safari中使用,但不能在Firefox / IE中使用

[英]javascript redirect form working in Chrome/Safari, but nor Firefox/IE

I am trying to create a redirect after visitor inputs an access code for a promotional campaign. 访问者输入促销活动的访问代码后,我试图创建重定向。 It works fine in OS X Chrome & Safari and Windows Chrome, but not OS X Firefox or Windows IE & Firefox. 它可以在OS X Chrome和Safari和Windows Chrome中正常运行,但不能在OS X Firefox或Windows IE&Firefox中运行。

Website is located at https://www.preciousmetals.com/offer12 网站位于https://www.preciousmetals.com/offer12

I have this script in the head… 我脑子里有这个剧本...

<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>

And this in the body… 而这在体内...

<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>

You really should not validate a password with javascript like that. 您确实不应该使用javascript验证密码。 It's a big security issue. 这是一个很大的安全问题。

If you want to do it anyway try this: 如果您仍然想这样做,请尝试以下操作:

<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>

Notice that I removed the form and replaced the button code 请注意,我删除了表单并替换了按钮代码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 可以在Chrome中正常工作的JavaScript jQuery代码,而不能在Firefox,Safari,IE中运行 - Simply javascript jQuery code working in Chrome, not Firefox, Safari, IE Javascript / jQuery无法在Firefox,Safari和IE中运行。 精通Opera和Chrome - Javascript/jQuery not working in Firefox, Safari and IE. Fine in Opera and Chrome JavaScript代码仅在Chrome中有效,而在Firefox,IE,Opera和Safari中无效 - JavaScript code working only in Chrome but not in Firefox, IE, Opera and Safari Ajax 调用/javascript - 在 IE、Firefox 和 Safari 上运行良好,但在 Chrome 上运行不正常 - Ajax call/javascript - working fine on IE, Firefox and Safari but not on Chrome Javascript年龄门无法在Chrome上运行,在Firefox,IE,Safari中可以正常使用 - Javascript age gate not working on Chrome, fine in Firefox, IE, Safari 表单验证不适用于Chrome和Firefox - Form validation not working in chrome nor firefox 我的简单Javascript代码可在Safari上运行,但不能在Chrome,Firefox或Opera上运行,这怎么了? - My simple Javascript code is working on Safari, but not Chrome, Firefox nor Opera, Whats wrong? Javascript在Safari中运行,但不适用于Chrome或Firefox - Javascript working in Safari but not Chrome or Firefox Javascript 表单验证代码适用于 FireFox 和 Chrome,但不适用于 Safari(在单选按钮上) - Javascript form validation code working on FireFox and Chrome but not on Safari (on radio button) Javascript书签可在Chrome / Safari中运行,但不能在Firefox / IE中运行 - Javascript Bookmarklet Works in Chrome/Safari but not Firefox/IE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM