2012-03-07 87 views
2

我期待創建一個表面上非常基本的在線表單。從瀏覽器地址欄中複製網址並使用html粘貼到表單中?

目標是創建一個帶有提交按鈕的mailto表單,在提交時將當前的 url與在瀏覽器地址欄中複製並粘貼到mailto電子郵件窗口中。

形式本身是直截了當:

form method="post" action="mailto:[email protected]"> 
Report a broken link, please use the submit button below. The URL for the broken link will be included automatically. 
<br /> 
<input type="submit" value="Submit"> 
</form 

越簡單越好,HTML/JAVA是首選......建議?

回答

1

我建議你使用javascript的document.URL獲取URL,並做任何你想做的事情。

1

試試這個

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'> 
</script> 
    <script type='text/javascript'> 
//<![CDATA[ 
    $(window).load(function(){ 
    var url = "mailto:[email protected]?Subject=" + window.location; 
    $('#mailtoLink').attr('href', url); 
    window.alert($('#mailtoLink').attr('href')); // = url; 
    });//]]> 
    </script> 
</head> 
<body> 
    Some Text <a id="mailtoLink" href="mailto:[email protected]" name="mailtoLink">Send Mail</a> 
</body> 
</html> 
相關問題