Skip to main content
Participant
May 6, 2010
Question

Attaching Javascript to a button?

  • May 6, 2010
  • 1 reply
  • 962 views

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!)

This topic has been closed for replies.

1 reply

Captiv8r
Legend
May 6, 2010

Hi there

Often things like JavaScript won't work properly until you add the location where you are running the file to the list of trusted folders in Flash. This is described in the link below.

Click here to view

Cheers... Rick

Helpful and Handy Links

Captivate Wish Form/Bug Reporting Form

Adobe Certified Captivate Training

SorcerStone Blog

Captivate eBooks