miojamo
miojamo

Reputation: 747

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?

Upvotes: 2

Views: 322

Answers (2)

rbhro
rbhro

Reputation: 208

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

Upvotes: 1

Gumbo
Gumbo

Reputation: 655239

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>');

Upvotes: 3

Related Questions