mobile menu

Send email link after test

You are here
Send email link after test

View and Edit HTML

Published tests appear in the /www/publish/ directory, which is in the MCS root install. The pages are in HTML format.

All tests have the ability to pass results to a JavaScript function upon completion. This example uses a basic speed test.

Open the page in a text/HTML editor and add the parameter shown below.

js speed param
Fig 1: Highlighting the example parameter required to pass results to a JavaScript function.

The parameter code is shown below for copy and paste purposes

<param name="js" value="testend($SPEED.DSPEED$,$SPEED.USPEED$,$SPEED.QOS$,

The JavaScript

Now that the test is set up to pass the results to the testend function it's time to create that function. The function needed for this example is below. It can be copied and pasted.

<script type="text/javascript">
var _ebody;
var bodyPct = escape("%");
function addCommas(n) {
var s=""+n;
var len = s.length;
for (var at=len-3; (at>0); at-=3) {
s = s.substring(0,at)+","+s.substring(at);
return s;
function testend(dspeed,uspeed,qos,rtt,maxp) {
_ebody = "Visualware MySpeed Test Results\n\n";
_ebody += "The MySpeed test results below show Speed and Quality measurements\n";
_ebody += "\n";
_ebody += "URL: " + location.href+"\n";
_ebody += "When: " + new Date()+"\n";
_ebody += "Download: " + addCommas(dspeed)+" bps\n";
_ebody += "Upload: " + addCommas(uspeed)+" bps\n";
_ebody += "QOS: " + qos + bodyPct +"\n";
_ebody += "RTT: " + rtt+" ms\n";
_ebody += "MaxPause: " + maxp+" ms\n";
 var s = '<a href=";subject=MySpeed Test Results&amp;';
s += 'body="'+_ebody+'"><b>Click to email these results</b></a><br><br>';
document.getElementById('elink').innerHTML = s;

So, what does the function do?

Simply, the testend function builds the email body into a variable named _ebody. The body of the email is then appended to a mailto link, that will be actioned when a user clicks the email link.

Email Link Div

The JavaScript in the last step looks for a <div> to place the email link. Add this <div> where the email link should appear on the page.

<div id="elink"></div>


Click here for a live example!