开发者

Problem with string assignment statement in IE [JavaScript]

I'm facing some weird problem in JavaScript string assignment statement. The 'markup' is a string variable which has data as HTML tags-

var markup= "<div id="element" ><link href="http://test.com/css/web.css" rel="stylesheet"><div class="testClass"><span></span></div>";

this.el.dom.innerHTML = markup;

In IE, After assigning this string to innerHTML of an ExtJs element it strips all like and style tags and this.el.dom.innerHTML contains following value-

"<div id="element" ><div class="testClass"><span></span></div>";

Can anyone please help me to figure out why this is happening?

Note: The assignment statement works file in Firefox and Chrome.

EDIT: The markup variable is passed as a parameter to the function so I think I don't have mu开发者_JS百科ch control over changing quotes.


Try:

var markup= '<div id="element" ><link href="http://test.com/css/web.css" rel="stylesheet"><div class="testClass"><span></span></div>';

You kept opening and closing the statement with the different quotation marks, so instead wrap the entire string with single tick marks so you can continue to use the " marks throughout the string.


try

var markup= '<div id="element" ><link href="http://test.com/css/web.css" rel="stylesheet"><div class="testClass"><span></span></div>';

this.el.dom.innerHTML = markup;


You should write

 var markup= "<div id=\"element\" ><link href=\"http://test.com/css/web.css\" rel=\"stylesheet\"><div class=\"testClass\"><span></span></div>";
 this.el.dom.innerHTML = markup;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜