How to create a bookmark button that sends the whole page as email .
Put something like this within the head section of your HTML document, or better yet, skip the script tags and
put it in an external file and link to it in the head section instead:
<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>
And this somewhere in the body section of your HTML document:
<input type="button" name="Bookmark this page" onclick="bookmark()" />
or...
Simple link:
<a
href="javascript:bookmark()">Click here to bookmark this page
</a>
HTML content of a page is a bit harder to send, you can use this to send the page's text in an email like this -
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.
The bookmark will be -
"javascript:if (document.all) window.open('mailto:[email protected]?body=' + document.body.innerText); else window.open('mailto:[email protected]?body=' + document.body.textContent);"
EDIT: For this to work, you'll have to create a link, and you'll have to right-click it and click "Add to Favorites".
<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>
I played with your question a little bit, done it with jquery ($('html').html()), and everything seemed fine for a moment.. BUT.. after I tried to email the whole content it didn't work either. When I got why it did not work I laughed - url too long, dude, software won't open it. Tested even on hard-coded string - short content opened the mail client fine, long did not.
Forgetaboudit.
If you want to read the html with javascript so hard, you can do it, but you have to send it via post to your server and mail it from there. Cheerz
ps. try with some test short html content and then with a whole casual webpage
$(document).ready(function(){
$("#testlink").click(function() {
$('#trick').text($("html").html().replace(/[\r\n]+/g, "%0A"));
window.open('[email protected]?body='+$('#trick').html(), 'email', '');
});
});