如何使用javascript创建书签按钮?

如何使用javascript创建书签按钮?,javascript,email,Javascript,Email,如何创建一个书签按钮,将整个页面作为电子邮件发送。将类似的内容放在标题中 HTML文档的一节,或者更好,跳过脚本标记和 将其放在外部文件中,并在标题部分链接到它: <script language="JavaScript" type="Text/Javascript"><!-- // var url = " "; //u can add ur url var pageName = "Client side programming"; function bookmark()

如何创建一个书签按钮,将整个页面作为电子邮件发送。

将类似的内容放在标题中 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>

或
简单链接:

页面的HTML内容更难发送,您可以使用此功能在电子邮件中发送页面文本,如下所示-

if (document.all)
    window.open("mailto:email@email.com?body=" + document.body.innerText); //For IE
else
    window.open("mailto:email@email.com?body=" + document.body.textContent); //For FF et al.
书签将被删除-

"javascript:if (document.all) window.open('mailto:email@email.com?body=' + document.body.innerText); else window.open('mailto:email@email.com?body=' + document.body.textContent);"
编辑:要使其工作,您必须创建一个链接,并右键单击它,然后单击“添加到收藏夹”


我稍微处理了一下你的问题,用jquery($('html').html()完成了它,然后一切似乎都很好。。但是在我尝试通过电子邮件发送全部内容后,它也不起作用。当我明白为什么它不起作用时,我笑了——url太长了,伙计,软件无法打开它。即使在硬编码的字符串上进行了测试,短内容也能很好地打开邮件客户端,而长内容则不能

伪造塔布迪特

如果你想用javascript阅读html,你可以这样做,但是你必须通过post发送到你的服务器并从那里邮寄出去。切雷斯

另外,尝试一些测试简短的html内容,然后是一个完整的休闲网页

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

这只会给页面添加书签,但不会在电子邮件中发送。但我需要完整的内容看看我的文章的编辑版本,你必须为同样的内容创建一个超链接。我知道我做这件事有点晚;-)但请尝试下一页。这是满足你需求的完美解决方案:你是说书签吗?你可以通过bookmarklet加载任何你想要的内容,但这不会改变它可能无法工作的事实(根据我的结论)。也许告诉我们“为什么”,这个想法有点疯狂。
$(document).ready(function(){           
        $("#testlink").click(function() {
            $('#trick').text($("html").html().replace(/[\r\n]+/g, "%0A"));
            window.open('email@email.com?body='+$('#trick').html(), 'email', '');
        }); 
    });