Javascript line break issues with SL 360

I'm having some issues with a project I'm working on in Storyline 360. I'm actually updating an old file from SL1 (that works fine in SL2) to 360. 

I'm recreating it, rather than just opening the file, to make sure I understand "proof of concept".

Basically I'm trying to run javascript that will take some text and append it to the end of exiting text with a line break in between. 

This is the code I'm using:

var p = GetPlayer(); 
var newNote = p.GetVar("newNote"); 
var allNotes = p.GetVar("allNotes") ; 
p.SetVar("allNotes",allNotes+"\n"+newNote);
p.SetVar("newNote",""); 

The problem seems to occur in the fourth line...where the "\n" is parsed by SL 360 as a space rather than a new line.

This same code works in SL1 and SL2 as intended (both in Flash and HTML5--on Chrome browser), but not in 360.

Has there been a change to how 360 handles javascript, or am I just missing something in the code I copied from the working file?

Thanks for the assist.

12 Replies
Justin Grenier

Thanks for the report, Adam and Nancy.

I don't know JavaScript from a hole in the ground, but I dropped this into a JavaScript Trigger:

var mytext = "Line 1 \n Line 2"

alert(mytext);

...and got this:

JS Alert with Newline Character

I bet my code is missing something, though.  Can you help me construct JavaScript code that reproduces the problem without depending on your project-specific content?

Thanks!

Adam Cannon

Justin, 

Thanks for the response. That code works for me, but I don't think Articulate is the program throwing up the alert window. I believe that's coming from the browser.

That being said, I'm not exactly sure what your request is. The code I posted in the original message is the code I used for both the SL2 and SL360 projects. There's nothing project specific about it. In fact it came from James Kingsley's blog: https://elearningenhanced.com/blog/2013/08/05/append-new-text-storyline-variable-and-print-variable

Justin Grenier

Thanks for the link, Adam.

I was looking for reproducible code that I could drop into our JavaScript editor without depending on the existence of specifically-named variables in a project, but I'll definitely read through the article you supplied and see if I can reproduce the problem that way.  Have a great weekend!

Ashley Terwilliger

Hi all,

Great news! Articulate 360 Update 4  was just released, and included a number of fixes which you can see in the release notes available here.  The item you all may be particularly interested in is how it fixed an issue where newline characters wouldn't display in HTML5 output when variables were updated via JavaScript.

Just launch the Articulate 360 desktop app on your computer and click the Update button for Storyline 360. Details here.

Let us know if you have any questions, either here or by reaching out to our Support Engineers directly.