开发者

W3C HTML in JavaScript validation

I have JavaScript in my template file, because of the smarty can't include the file and I have W3C problem validation:

addMarker({$item->lat}, {$item->lng}, '<div style="height: 2开发者_如何学Go80px;">dfdsfsd</div>');

Error element not allowed.

Is there a way to escape it somehow?


Split the start-tag and end-tag open delimiters:

addMarker({$item->lat}, {$item->lng}, '<'+'div style="height: 280px;">dfdsfsd<'+'/div>');

Or replace them by escape sequences:

addMarker({$item->lat}, {$item->lng}, '\x3Cdiv style="height: 280px;">dfdsfsd\x3C/div>');


Better split it '<d' + 'iv and also the end tag otherwise you'll get an "end tag without start tag" error.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜