Attaching Javascript to a button?
I've tried to attach a script to Submit button that would launch the email app, open a new email, populate the To:, Subject: and Body: fields (the body field with a simple list of questions for the user to complete).
In the past I have used HTML attached to the button using the "Open URL or File" action, but this also launched IE and resulted in a browser screen with an 'Action Cancelled' message, whilst the email app was loading in the background. Users found this confusing, and the less-confident IT users became befuddled by the Action Cancelled screen and 9 times out of 10, closed down all the apps running. Therefore I thought the js would simplify / streamline the process.
I create the button and choose: On Success...Execute Javascript> insert my script> apply>save>publish. The button doesn't work. In fact, if I copy some script from a test site and attach it to the button, it still doesn't work. Is it me?
Here is the Javascript that I'm trying to execute:
<script type="text/javascript">
{
var daReferrer = document.referrer;
var email = "test.admin@midyorks.nhs.uk";
var subject = "I have successfully completed my WinDIP elearning assessment";
var body_message = "Please complete the following details and then send the email: %0A %0AName: %0AJob Title: %0ADepartment: %0AWork Phone: %0ALine Manager: %0A %0AOnce your email is received the EDMS administrator will set up your access to the WinDIP application. If you require any further assistance or training on WinDIP, please contact test.admin@midyorks.nhs.uk or ring 58491."
var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message;
win = window.open(mailto_link,'emailWindow');
if (win && win.open &&!win.closed) win.close();
}
</script>
I'm reletively new to js but have used Captivate for a while, and can't figure out where I've gone wrong with this one!
Many thanks for any suggestions!
Annie (BTW, that isn't my email address, so please don't send email to it!)