Can someone check my JS?

Jul 07, 2015

Hiya,

Could someone please check this javascript please, it's not running properly:

var myWindow = window.open(""," Print","width=810,height=610,menubar=1,scrollbars=1,resizable=1, toolbar=1");

var player=GetPlayer();

var unotes1 = player.GetVar("TextEntry1");

unotes1 = unotes1.replace(/\r\n/g, '<br />').replace(/[\r\n]/g, '<br />');

var contents = "<html><head><title>What I know about FMEA</title></head>

<body style='width:650px;padding:20px;'>"
contents+="<div style='font-size:17px;margin-top:20px; margin-bottom:20px; font-family:Helvetica, Arial, sans-serif;line-height:22px;'><img src="images/logo.png"/></div>";

contents+="<div style='font-size:17px;margin-top:20px; margin-bottom:20px; font-family:Helvetica, Arial, sans-serif;line-height:22px;'>What I know about FMEA</div>";

contents+="<div style='font-size:17px;margin-top:20px; margin-bottom:20px; font-family:Helvetica, Arial, sans-serif;line-height:22px;'>"+unotes1+"</div>";

contents+="</body></html>"

myWindow.document.write(contents);
myWindow.document.close();
myWindow.focus();
myWindow.print();

3 Replies
Jackson Hamner

Give this a try:

var myWindow = window.open(""," Print","width=810,height=610,menubar=1,scrollbars=1,resizable=1, toolbar=1");

var player=GetPlayer();

var unotes1 = player.GetVar("TextEntry1");

unotes1 = unotes1.replace(/\r\n/g, '<br />').replace(/[\r\n]/g, '<br />');

var contents = "<html><head><title>What I know about FMEA</title></head><body style='width:650px;padding:20px;'>"
contents+="<div style='font-size:17px;margin-top:20px; margin-bottom:20px; font-family:Helvetica, Arial, sans-serif;line-height:22px;'><img src='images/logo.png'/></div>";

contents+="<div style='font-size:17px;margin-top:20px; margin-bottom:20px; font-family:Helvetica, Arial, sans-serif;line-height:22px;'>What I know about FMEA</div>";

contents+="<div style='font-size:17px;margin-top:20px; margin-bottom:20px; font-family:Helvetica, Arial, sans-serif;line-height:22px;'>"+unotes1+"</div>";

contents+="</body></html>"

myWindow.document.write(contents);
myWindow.document.close();
myWindow.focus();
myWindow.print();

I think the problem was this:<body style='width:650px;padding:20px;'>" was added as a second line when it should have been part of the string on the previous line

This discussion is closed. You can start a new discussion or contact Articulate Support.