Change JS code in Inspect Element Editor

15,930

Solution 1

In my experience, the edits I've made to Javascript files have been reflected immediately. However, an easy fix you might try is as follows:

  • Insert a breakpoint on the line you want to edit
  • Reload the page (breakpoints will persist)
  • Edit that line when the breakpoint is hit
  • Click Continue on the debugger

If you need more information on breakpoints and the debugger, check out this link

If you want even more information on using the inspector tool, try searching through this tutorial

Solution 2

Altering the JavaScript of a page through the browser is considered a malicious practice. Imagine that someone removes all the logic from you login method and then has it return true;.

Malicious users could exploit your system by making targeted changes to your system. So browsers prevent you from making those changes live.

If you really wanted to, I guess you could download all the source files, make your changes and then have a browser load the project. The project should preserve your changes. Although, the webmaster probably has mechanism in place to prevent any incoming requests to his server from Cross Origin (XSS). Recognizing that the edited requests are not coming from the correct origin, the server should reject and potentially try to log/track the malicious attempt.

Share:
15,930
Vivek Sadh
Author by

Vivek Sadh

Updated on June 25, 2022

Comments

  • Vivek Sadh
    Vivek Sadh almost 2 years

    When I make some changes in html content using Chrome's Inspect Element editor the changes are immediately reflected. But when I make a change in Javascript code then the changes are not reflected.

    Suppose on click of a button I say, alert "John is a Good boy" and When I change it to "John is a bad boy" using Inspect element(JS code) then the changes are not reflected on button click and the old text "John is a Good boy" gets displayed.

    So when a page gets loaded, its not possible to edit the JS code and see the changes ? Why is it so ?