javascript - IE10 (in compatibility mode) generates SCRIPT1015: Unterminated string constant error on valid code? -
i have few little jquery scripts in sharepoint utilize hard-coded paths include jquery , css, pain move around.
i thought i'd utilize js , document.write() include files using dynamically generated paths including site root url.
problem: have piece of think valid js code, ie10 spits out "unterminated string" error. if alter final '</script>' string else works ok (but of course of study doesn't result in valid html).
the code passes jslint few comments spacing. javascriptlint.com generates warning "script tag must empty if path specified", can prepare setting variable "imp" in 2 lines, firstly generating linktag, concatenating script tag.
code:
<script language="javascript"> var siteurl= l_menu_baseurl; var imp= '<link href="' + siteurl + '/siteassets/path/my.css" rel="stylesheet" type="text/css"/>\n' + '<script language="javascript" src="' + siteurl + '/lib/js/jquery-1.9.1_min.js">' + '</script>\n'; </script> i have been staring @ long, it's simple. i'm building html string here ie seems interpreting final </script> tag, ignoring fact it's literal string in quotes.
any ideas?
ie seems interpreting final </script> tag, ignoring fact it's literal string in quotes
this what's happening. 1 solution utilize '</scr'+'ipt>'. break closing tag, it's not interpreted close tag.
var imp= '<link href="' + siteurl + '/siteassets/path/my.css" rel="stylesheet" type="text/css"/>\n' + '<script language="javascript" src="' + siteurl + '/lib/js/jquery-1.9.1_min.js">' + '</scr' + 'ipt>\n'; edit: can this
... + '<\/script>\n'; javascript internet-explorer
No comments:
Post a Comment