Click to See Complete Forum and Search --> : unterminated string literal syntax error


hapster
09-18-2003, 07:04 AM
Up front Javascript comprises less than 1% of my experience. All I use I’ve found thanks to those who donate.

I’ve found a script that I wish to use to open a full screen pop-up from a link. Despite having ‘instructions’ I can’t get it to work. I’ve tried contacting the author but have not been able to get a helpful response.

I’m hopping that someone can take a look and advise me what needs fixing.

I’ll paste below, as I found it, the script (with its instructions) and highlight the error "unterminated string literal". In trying to fix it I created multiple errors - so time for help if someone can.


Script purpose: open Full Screen pop-up and other boarderless sized windows

<head>
<script>
// set the popup window width and height
var windowW=214 // wide
var windowH=398 // high
// set the screen position
var windowX = 260 // from left
var windowY = 100 // from top
// set the url
var urlPop = "fs.html"
// set the title of the page
var title = "Full Screen Pop-Up"
// set this to true if the popup should close
// upon leaving the launching page; else, false
var autoclose = true
// ============================
// do not edit below this line
// ============================
s = "width="+windowW+",height="+windowH;
var beIE = document.all?true:false
function openFrameless(){
if (beIE){
NFW = window.open("","popFrameless","fullscreen,"+s)
NFW.blur()
window.focus()
NFW.resizeTo(windowW,windowH)
NFW.moveTo(windowX,windowY)
var frameString=""+
"<html>"+
"<head>"+
"<title>"+title+"</title>"+
"</head>"+
"<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
"<frame name='top' src='"+urlPop+"' scrolling=auto>"+
"<frame name='bottom' src='about :blank' scrolling='no'>"+
"</frameset>"+

" // ERROR - unterminated string literal

<script language="JavaScript">
<!--
window.open = SymRealWinOpen;
//-->
</script>
</html>"
NFW.document.open();
NFW.document.write(frameString)
NFW.document.close()
} else {
NFW=window.open(urlPop,"popFrameless","scrollbars,"+s)
NFW.blur()
window.focus()
NFW.resizeTo(windowW,windowH)
NFW.moveTo(windowX,windowY)
}
NFW.focus()
if (autoclose){
window.onunload = function(){NFW.close()}
}
}
</script>
</head>
<body onload="var SymTmpWinOpen = window.open; window.open = SymWinOpen; // ERROR - SymWinOpen is not defined
top.window.focus(); window.open = SymTmpWinOpen;">
<a href="javascript<img src="images/smilies/redface.gif" border="0" alt="">penFrameless()">open FS</a>
</body>

// Making the Frameless Popup Center on the Screen
// Comment out the two lines as shown, and add the two shown below them.

// set the screen position where the popup should appear

//var windowX = 260 // from left
//var windowY = 100 // from top
var windowX = (screen.width/2)-(windowW/2);
var windowY = (screen.height/2)-(windowH/2);

Gollum
09-18-2003, 08:09 AM
I think the errors say it all.

the unterminated string literal is because the " char at the beginning of the line is not terminated by another one before the end of the line. Javascript does not support strings that extend over multiple lines of code.
try this...

"<script language=\"JavaScript\">\n" +
"<!--\n" +
"window.open = SymRealWinOpen;\n" +
"//-->\n" +
"</script>\n" +
"</html>"


// ERROR - SymWinOpen is not defined
I can't find it either. You will need to define it somewhere.

hapster
09-18-2003, 08:33 AM
Thanks it did solve the original problem but caused another... This is how I've been going on for days. Now it generates this error:
"<frame name='bottom' src='about:blank' scrolling='no'>"+
"</frameset>"+
"<script language=\"JavaScript\">\n" +
"<!--\n" +
"window.open = SymRealWinOpen;\n" +
"//-->\n" +
"</script>\n" + // Unterminated string literal
"</html>"
NFW.document.open();
NFW.document.write(frameString)
NFW.document.close()

Thanks for your help and anymore would be very much appreaciated

Gollum
09-18-2003, 08:50 AM
Oops, forgot about that one...

change that line to...

"<\/script>\n" +


The browser was noticing the string sequence </script> and it thought it was the end of the script despite it being inside a javascript string.

hapster
09-18-2003, 09:12 AM
Thanks Gollum !!! that’s fixed that problem. Maybe one day soon I’ll pause and take in Javascript (shame they didn’t base it on 370 Assembler
I’d be made)

I still have the
// ERROR - SymWinOpen is not defined
Problem – could you offer any suggestions ?

(I originate from London UK and now party in Toronto… if you are ever this way I owe you a few bevies..)

hapster
09-18-2003, 10:02 AM
Not to worry Gollum... I've fixed it using my limited know how..

Thanks again for your help and I still owe the bevies..:)

hapster
09-18-2003, 10:39 AM
Not to worry Gollum... I've fixed it using my limited know how..

Thanks again for your help and I still owe the bevies..:)

Gollum
09-19-2003, 02:15 AM
Much obliged :cool:

I'm from NZ now working in London. It's people like us that keep the Earth spinning ;)