我有一個HostGator提供的基本的HTML/JavaScript聯繫表單。它工作得很好......如果用戶沒有提交名稱或無效的電子郵件地址,就會彈出一個JavaScript警報。這些警報將保留在屏幕上,直到用戶單擊確定。但是,如果用戶正確提交聯繫表單,最終成功提醒只能持續1/2秒左右。我試圖弄清楚如何在指定的時間內最後發送最終電子郵件成功警報,或者直到用戶點擊確定按鈕,然後將它們重定向到指定頁面。這裏是鏈接到HostGator信息的聯繫表格w/JavaScript http://www.hostgator.com/formmail.shtml,這裏是我試圖改變的代碼,以獲得提交後的JavaScript消息,而不是在用戶甚至有機會閱讀之前消失。Javascript提醒窗口 - 如何設置len
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>FormMail Demo</title>
<script type="text/javascript">
function hgsubmit()
{
if (/\S+/.test(document.hgmailer.name.value) == false) alert ("Please provide your name.");
else if (/^\[email protected][a-z0-9_.-]+\.[a-z]{2,6}$/i.test(document.hgmailer.email.value) == false) alert ("A valid email address is required.");
else if (/\S+/.test(document.hgmailer.comment.value) == false) alert ("Your email content is needed.");
else {
document.hgmailer.submit();
alert ('Thank you!\nYour email is sent.');
}
}
</script>
</head>
<body>
<form action="http://www.mydomain.com/cgi-sys/formmail.pl" method="post" name="hgmailer">
<input type="hidden" name="recipient" value="[email protected]">
<input type="hidden" name="subject" value="FormMail E-Mail">
Whatever you want to say here<br><br>
Visitor Name: <input type="text" name="name" size="30" value=""><br>
Visitor E-Mail: <input type="text" name="email" size="30" value=""><br>
E-Mail Content: <textarea name="comment" cols="50" rows="5"></textarea><br><br>
<input type="button" value="E-Mail Me!" onclick="hgsubmit();">
<input type="hidden" name="redirect" value="http://www.mydomain.com/redirect-path">
</form>
</body>
</html>
嘗試把警報()前提交() – anuragsn7 2012-04-08 09:31:15