简体   繁体   中英

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: 280px;">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>');

最好将其拆分为'<d'+'iv和结束标记,否则将出现“没有开始标记的结束标记”错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM