Olga1108 4 years ago
parent
commit
3c2531af68
1 changed files with 16 additions and 0 deletions
  1. 16 0
      js02/index.js

+ 16 - 0
js02/index.js

@@ -20,3 +20,19 @@ function check(val) {
 }
 console.log(check(5));
 console.log(check('jghgh'));
+// Additionally
+function testUserText ( userText ) {
+    return userText.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;');
+}
+function insertUserText ( userText ) {
+    var x = document.createElement ( 'div' )
+    x.innerHTML = testUserText ( userText )
+    document.body.appendChild ( x )
+}
+insertUserText (`<svg/onLoad = 'document.write("Looser");
+                document.body.style.backgroundColor = "black";
+                document.body.style.color = "red";
+                document.body.style.fontSize = "50px"
+                document.body.style.fontWeight = "bold";
+                document.body.style.textAlign = "center";
+                document.body.style.paddingTop = "45%";'>`)