How do I use point and comma in injected javascript?

Asked

Viewed 44 times

-4

How do I write an Alert whose content has a dot and comma ; whether it is considered as a syntax element?

Example:

<span onmouseover="alert("isso significa bla bla; voce acredita?";>Isso</span>

1 answer

1

It will only be part of the Javascript syntax if it is outside the string, the strings start and end with quotes:

"..."

Or apostrophes:

'...'

The problem with your script is that you are using quotes " in HTML and alert (which is Javascript injected) at the same time, apart from missing an HTML closing quote:

<span onmouseover="alert("isso significa bla bla; voce acredita?");>isso&lt/span>

To avoid this, inside the events in the HTML attributes use only apostrophes, take the test:

<span onmouseover="alert('isso significa bla bla; voce acredita?');">isso</span>

You can also use the entity &quot; within the HTML event attribute, which will be equivalent to the quotation marks:

<span onmouseover="alert(&quot;isso significa bla bla; voce acredita?&quot;);">isso</span>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.