简体   繁体   English

window.onload在邮件客户端上不起作用

[英]window.onload does not work on mail client

I have this script written in my original webpage: 我在原始网页上写了这个script

<script>
var marcoemail="aaaaaa";
   function pippo(){
      document.getElementById("marcoemailid").innerHTML=marcoemail;
   }
   window.onload = pippo;
</script>

But the mail client when sends the page to the email address, this script is not executed. 但是邮件客户端将页面发送到电子邮件地址时,不会执行此script I tried body.onload , document.onload , window.onload , but still it does not work. 我尝试了body.onloaddocument.onloadwindow.onload ,但仍然无法正常工作。

As stated in the comments, all known email clients ignores <script> tags and inline js in multi-part email content. 如评论中所述,所有已知的电子邮件客户端都会忽略<script>标签和多部分电子邮件内容中的内联js。 Also, some of the major email-clients such as Gmail webmail and, MSN webmail strips out the <head> tag all together so a general design rule is to keep everything (css) inline. 另外,一些主要的电子邮件客户端(例如Gmail网络邮件和MSN网络邮件)一起将<head>标记剥离在一起,因此一般的设计规则是保持所有内容(css)内联。

There is a good article bringing up scripts in email over at Campaign monitor . 有一篇很好的文章,在Campaign Monitor上通过电子邮件提出了脚本。

If you can, you should try to strip the html content from script tags prior to sending it as an email as content including script tags will have an effect on the email´s spam score in most spam filters. 如果可以的话,您应该尝试从脚本标签中删除html内容,然后再将其作为电子邮件发送,因为包含脚本标签的内容会影响大多数垃圾邮件过滤器中电子邮件的垃圾邮件评分。

Probably you're going a wrong way... 可能您走错了路...

Do this.... 做这个....

1 write a javascript code inside the page within <script></script> tag. 1在<script></script>标记内的页面内编写javascript代码。 here 这里

<script>
var marcoemail = "aaaa";
function pippo(){
   document.getElementById("marcoemailid").innerHTML=marcoemail;
}
</script>

You should execute this function on body onload event then you should be modified body tag like this 您应该在body onload事件上执行此功能,然后应像这样修改body标签

<body onload ="pippo()">

Now it will working fine.... 现在它将正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM