Example 2—Javascript—setting the day of the month

We will use Javascript to set the day of the month; you will notice the Javascript code between the html tags <script> to start the script and <\script> to end the script. The command var is very common in Javascript:

<!DOCTYPE html> 
<html> 
<body> 
<p>Click the button to display the date after changing the day of the month. </p> 
<button onclick="myFunction()">Try it</button> 
<p id="demo"></p> 
<script> 
function myFunction() { 
var d = new Date(); 
d.setDate (15); 
document.getElementById("demo").innerHTML = d; 
} 
</script> 
</body> 
</html> 

A XSS attack can be identified by looking for the command var and for a variable with the html tags <script> and </script>. Scripts with var are likely to be ...

Get CompTIA Security+ Certification Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.