When I change text using JavaScript The text does not appear in the HTML "View source". Is it possible to inject information to the HTML "View source". (When I write View source I mean to While you pressing on the right mouse button in the browser you can view the source code That returns from the server)
标签:
view-source
相关问题
- inject text from javascript to html “View source”
- how to get a full html source?
- Why are the checkboxes on my Webform invisible to
- How to check View Source in Mobile Browsers (Both
- Programmatically open “View Source” HTML Window in
When you "view source" in a browser, it is opening a window and printing the source code to the current page. This text is totally static, nothing will change its contents besides manually refreshing.
If you want the HTML source you are looking at to reflect changes you make to the page, you need to use your browsers Dev Tools. Try Right Click->Inspect Element instead of Right Click->View Source
Well,
You have said it right. When you "View source" you see what was received from the server, and elements that you added dynamically using javascript do not exist there.
If you want to see elements which you added later, you can do that using Inspect element (CTRL + SHIFT + I), which will show you current html structure displayed in browser.
View Source shows you only the HTML it received from the server's response. Your JS changes happen afterward.
Firebug and Chrome's debugger show you the source dynamically so you can see the DOM and HTML as it has been changed. But view source will only ever show you what the browser received from the server.
Some techniques:
In some browsers
Ctrl-A
to select the whole rendered page content and, with a right clickView Source
of selection, gives the source as generated by rendering scripts. (often<script>
elements are gone and replaced by the rendered content)Augment the address bar URI by prepending
view-source:
to get the original source.Use the menu bar or right click
View Source
interfaces.With these techniques and FF it is possible to get different sources for a "static" page in the rendering chronology.
Technique #1 is interesting when automated ... along the lines of:
quasi code: