Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1702 How can I use an external JavaScript source file to amend all the mailto links in a document such that it appends a generic subject line?

You are here: irt.org | FAQ | JavaScript | Link | Q1702 [ previous next ]

Try:

<html>

<body>

<a href="mailto:martin@irt.org">mailto:</a>
<br>
<a href="http://www.irt.org">http:</a>

</body>

<script language="JavaScript" src="mailto.js"></script>

</html>

And then in mailto.js:

for (var i=0; i<document.links.length; i++) {
  if (document.links[i].href.indexOf('mailto:') > -1) {
    document.links[i].href += '?subject=' + escape('Hello world');
  }
}

©2018 Martin Webb