Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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?

irt.org | Knowledge Base | JavaScript | Link | Q1702 [ previous next ]

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?

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');
  }
}

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.