2009-04-25 24 views

回答

-3

把下面的HTML文檔,或頭 部分中更好的是,跳過腳本標記和

把它放在一個外部文件,並鏈接到它的頭節,而不是:

<script language="JavaScript" type="Text/Javascript"><!-- // 
var url = " "; //u can add ur url 
var pageName = "Client side programming"; 
function bookmark() { 
if (window.external) { 
window.external.AddFavorite(url, pageName) 
} 
else { 
alert("Sorry! Your browser doesn't support function. 
Use the bookmark option in your browser instead."); 
} 
} // --></script> 

這某處HTML文檔的主體部分:

<input type="button" name="Bookmark this page" onclick="bookmark()" /> 

or... 

Simple link: 
<a 
href="javascript:bookmark()">Click here to bookmark this page 
</a> 
+1

這隻會將頁面加入書籤,但不會通過電子郵件發送。 – Kirtan 2009-04-25 10:34:49

3

頁面的HTML內容是有點難發送,您可以我們E本發送網頁的文字在一封電子郵件中這樣的 -

if (document.all) 
    window.open("mailto:[email protected]?body=" + document.body.innerText); //For IE 
else 
    window.open("mailto:[email protected]?body=" + document.body.textContent); //For FF et al. 

書籤將是 -

"javascript:if (document.all) window.open('mailto:[email protected]?body=' + document.body.innerText); else window.open('mailto:[email protected]?body=' + document.body.textContent);" 

編輯:對於這項工作,你必須創建一個鏈接,你必須右鍵單擊它並單擊「添加到收藏夾」。

<a href="javascript:if (document.all) window.open('mailto:[email protected]?body=' + document.body.innerText); else window.open('mailto:[email protected]?body=' + document.body.textContent);">Bookmark This</a> 
+0

但我需要的全部內容 – yesraaj 2009-04-25 12:48:52

+0

以上代碼爲+1 – yesraaj 2009-04-25 13:36:12

0

我打你的問題一點點,用jQuery做它($(「HTML」)。HTML()),一切似乎罰款了一會兒..但是..以後我試着發電子郵件整個內容也不起作用。當我明白爲什麼它不起作用時,我笑了 - 網址太長了,老兄,軟件無法打開它。即使在硬編碼的字符串上測試 - 短內容打開郵件客戶端很好,很久沒有。

Forgetaboudit。

如果你想用JavaScript來閱讀html這麼難,你可以做到,但你必須通過郵件發送到你的服務器並從那裏寄出。 Cheerz

ps。嘗試用一些測試簡短的HTML內容,然後用一個整體的休閒網頁

$(document).ready(function(){   
     $("#testlink").click(function() { 
      $('#trick').text($("html").html().replace(/[\r\n]+/g, "%0A")); 
      window.open('[email protected]?body='+$('#trick').html(), 'email', ''); 
     }); 
    });