Skip to main content
Participant
November 14, 2020
Question

Beware of escape-sequence control code when using javascript window in adobe captivate

  • November 14, 2020
  • 1 reply
  • 204 views

I've been a little surprised by something about to use javascript in captivate.
If you know of any of the following issues, or if anyone has had a similar experience, I'd like to hear some information about them.

All of the javascript below works perfectly fine in a typical console. (Obviously...)

1.This javascript is not working.
var uVarTest1 = "Hello";
var uVarTest2 = "World!";
alert(uVarTest1 + "\\n" + uVarTest2);

2.This works.
var uVarTest1 = "Hello";
var uVarTest2 = "World!";
alert(uVarTest1 + " " + uVarTest2);

I wondered if, perhaps, I shouldn't write control code directly in the alert parameters, so I did the following.

3.This doesn't work.
var uVarTest1 = "Hello\\nWorld!";
alert(uVarTest1);

4.This works.
var uVarTest1 = "Hello World!";
alert(uVarTest1);

I was perplexed... I also ran the following tests, just to be sure.

5.This doesn't work.
//This is just a comment!
//Hello \n World!
var uVarTest1 = "Hello World!";
alert(uVarTest1);

6.This works
//This is just a comment!
//Hello n World!
var uVarTest1 = "Hello World!";
alert(uVarTest1);

In other words, when you type in the javascript window, the control code seems to be interpreted immediately. Even if you are commenting out it !!
This means it's not a simple matter of not being able to carriage return.

This could be a surprising source of bugs.

7.This works, but no line feeds (the alert message in adobe captivate different from the typical console. That's another issue.)
var uVarTest1 = "Hello";
var uVarTest2 = "World!";
var uVCRLF = String.fromCharCode(13) + String.fromCharCode(10);
alert(uVarTest1 + uVCRLF + uVarTest2);

I apologize in advance for my poor English.

Thanks.

    This topic has been closed for replies.

    1 reply

    Participant
    November 14, 2020
    Sorry. There were some mistakes in the description.

    ×)//n -> /n

    1.This javascript is not working.
    var uVarTest1 = "Hello";
    var uVarTest2 = "World!";
    alert(uVarTest1 + "\n" + uVarTest2);

    2.This works.
    var uVarTest1 = "Hello";
    var uVarTest2 = "World!";
    alert(uVarTest1 + " " + uVarTest2);

    I wondered if, perhaps, I shouldn't write control code directly in the alert parameters, so I did the following.

    3.This doesn't work.
    var uVarTest1 = "Hello\nWorld!";
    alert(uVarTest1);

    4.This works.
    var uVarTest1 = "Hello World!";
    alert(uVarTest1);