JavaScript injection is the process of inserting JavaScript code into a web page or address bar, or the process of detecting XSS vulnerabilities on a website. Note that only you will see these changes and are not permanent because JavaScript is a client-side programming language.
Steps
Method 1 of 1: JavaScript Injection

Step 1. Enter the code in the address bar
Try the following "injections":
- Note that if you are using Firefox, you will have to use a different method, such as cmd-shift-k on a Mac.
- javascript: alert ("Hello!");
- Opens a window with the word "Hello!"

2 javascript: alert ("Hello"); alert ("world");
Opens two windows: the first with the word "Hello"; when you click "OK" a second window will open with the word "world":

3 javascript: alert (document.forms [0].to.value = "other")
Changes the value of form [0] to "other"

4 javascript: void (document.bgColor = "blue")
Changes the background color to blue. You can make the background color whatever you want - to do this, instead of "blue" (blue) enter another color (in English)

Step 5.javascript: alert ("Real url:\ t \ t "+ location.protocol +" "+ location.hostname +" / "+" \ nAddress URL: \ t \ t "+ location.href +" \ n "+" \ nIf the names do not match, this is spoofing. ");
Displays the real name of the site server you are viewing. Use this code if you think you are viewing a fake website, or just for verification

6 javascript: R = 0; x1 =.1; y1 =.05; x2 =.25; y2 =.24; x3 = 1.6; y3 =.24; x4 = 300; y4 = 200; x5 = 300; y5 = 200; DI = document.images; DIL = DI.length; function A () {for (i = 0; i-DIL; i ++) {DIS = DI [i].style; DIS.position = 'absolute'; DIS.left = Math.sin (R * x1 + i * x2 + x3) * x4 + x5; DIS.top = Math.cos (R * y1 + i * y2 + y3) * y4 + y5} R ++} setInterval ('A ()', 5); void (0);
Makes photos fly across the screen. Find a site similar to Google Images to download more images from it. (If you hit the refresh button, the code will work very quickly, but it may only work on macOS.)

7 javascript: R = 0; x1 =.1; y1 =.05; x2 =.25; y2 =.24; x3 = 1.6; y3 =.24; x4 = 300; y4 = 200; x5 = 300; y5 = 200; DI = document.images; DIL = DI.length; function A () {for (i = 0; i-DIL; i ++) {DIS = DI [i].style; DIS.position = 'absolute'; DIS.left = Math.cos (R * x1 + i * x1 + x2) * x4 + x5; DIS.top = Math.cos (R * y1 + i * y2 + y3) * y4 + y5} R ++} setInterval ('A ()', 5); void (0);
Makes the photos form a circle

8 javascript: document.body.contentEditable = 'true'; document.designMode = 'on'; void 0
Moves elements around the web page
Advice
-
If you are using a browser whose address bar is also a search bar (as in Google Chrome, for example), select the address bar function instead of the search bar when entering your JavaScript code.
- The changes made are not permanent and will not affect the information on the server.
- Only you will see the changes you make.
- You can only change the background for pages that do not yet have a CSS background.