Javascript “电子邮件当前页面”按钮在Chrome中不起作用
我在一个网站上有一段代码,可以通过电子邮件发送当前页面。它可以在Firefox上运行,但不能在Chrome上运行。我在谷歌上搜索了这个问题,但没有找到任何答案。我做错什么了吗Javascript “电子邮件当前页面”按钮在Chrome中不起作用,javascript,google-chrome,Javascript,Google Chrome,我在一个网站上有一段代码,可以通过电子邮件发送当前页面。它可以在Firefox上运行,但不能在Chrome上运行。我在谷歌上搜索了这个问题,但没有找到任何答案。我做错什么了吗 <script> function emailCurrentPage(){ // In comments, other things I've tried //window.location.href="mailto:?subject="+document.title+"&
<script>
function emailCurrentPage(){
// In comments, other things I've tried
//window.location.href="mailto:?subject="+document.title+"&body="+escape(window.location.href);
//document.location.href="mailto:?subject="+document.title+"&body="+escape(document.location.href);
document.location="mailto:?subject="+document.title+"&body="+escape(document.location);
}
</script>
<button onclick="emailCurrentPage();">
Send by email
</button>
谢谢。更改您的功能:
window.location.href="mailto:?subject="+document.title+"&body="+encodeURI(document.location);
在最新版本的Chrome中,这个按钮对我来说似乎工作得很好@很奇怪,你的小提琴在我的Chrome版本中也能用。。。所以问题可能不是实际的代码,而是其他的东西。我只是不明白为什么它在FF中仍然有效。