2010-02-15 97 views
0

因此,我試圖讓用戶點擊一個按鈕給我發電子郵件,一個js提醒框彈出一條消息,然後他們點擊確定後,它會繼續使用電子郵件鏈接。這是我到目前爲止的代碼:Javascript alert box

<a href="mailto:[email protected]"> 
<a href='javascript:window.alert("All reservations must be made by phone!");'> 
<img src="http://wfithaca.com/wp-content/themes/zenlite/images/mailicon.png" /> 
</a> 
</a> 

任何幫助將不勝感激!

回答

4

嘗試:

<a href="mailto:[email protected]" onclick="alert('All reservations must be made by phone!');"> 
<img src="http://wfithaca.com/wp-content/themes/zenlite/images/mailicon.png" /> 
</a> 
+1

+1好的,簡單和優雅降級。 – 2010-02-15 22:00:49

+0

輝煌......從未想過它...... – 2010-02-15 22:03:49

+0

太棒了!簡短,甜美,正是我所需要的。非常感謝! – Davey 2010-02-15 22:04:07

1
//javascript 

function alertAndRedirect(text, email) { 
alert(text); 
window.location.replace("mailto:" + email); 
} 

<!--HTML --> 
<a href='javascript:alertAndRedirect("All reservations must be made by phone!","[email protected]");'> 
<img src="http://wfithaca.com/wp-content/themes/zenlite/images/mailicon.png" /> 
</a> 

希望這有助於...