即使在onclick返回true之後,我仍然遇到鏈接不存在的問題。它在Chrome和Firefox中運行良好。我注意到只有錨的這一特定行爲是tag.I現在用引導的反應(不知道這是影響..)即使在onclick =「return true;」之後,IE11並沒有跟蹤鏈接
樣品:
<form>
<a id="SignonButton" class="SignonButton" HREF="https://www.google.com" onClick="return true;">
<button type="button" class="btn btn-primary" id="button1" name="button1">Inside form doesnt work</button>
</a>
</form>
<a id="SignonButton" class="SignonButton" HREF="https://www.google.com" onClick="return true;">
<button type="button" class="btn btn-primary" id="button1" name="button1">Outside form works</button>
</a>
@TJ確實是這樣,它的工作。 其實我改造現有一個形式,使之響應的形式具有兩個動作和兩個輸入元素 1. HREF =「使用Javascript:transferRequest()」 2.的onClick =「validateRequest()」
形式具有兩個輸入元素input1:email和input2:密碼。
什麼我可以從現有代碼不解的是,validateeRequest()驗證電子郵件方式([email protected])和密碼alphanum模式並返回true
如果兩個模式相匹配。
驗證請求檢查兩個文本框以確認輸入的文本相匹配的圖案或沒有(不驗證只是檢查,如果模式匹配與否,轉印
請求實際上兩個文本傳送,因爲它是服務器)。
建議使用<a>
爲按鈕是正確的,或者我需要添加驗證方法到按鈕 我不允許完全修改網站,只是將其轉換爲響應。
<div>
<label for="email">Email</label>
<input type="TEXT" size="16" maxlength="19" autocomplete="OFF">
</div>
<div>
<label for="Password" >Password</label>
<input type="PASSWORD" size="16" maxlength="19" autocomplete="OFF>
</div>
<div>
<a id="SignonButton" HREF="javascript:transferRequest('verify')" onClick="return ValidateRequest('Verify');">
<button type="button" class="btn btn-primary" id="button1" name="button1">Inside form doesnt work</button>
</a>
</div>
</form>
function transferRequest()
{
var form = document.loginForm;
document.loginForm.submit();//submits to local exchange server
//some crazy validation
}
function validateRequest()
{
// code to check if the email input follows pattern ([email protected]) or not
// code to check if the password has alphanum as pattern or not
//return true if both pattern matches
}
可能是由於一個互動的元素(''