简体   繁体   中英

firefox view source code

I noticed that the source code shown in Firefox appears to be incomplete. I have the latest version. When using the Firebug plugin to look at a webpage, I am able to find elements which are simply not recognized by Firefox.

This is for a automated script I am working on.

I am wondering several things:

  1. Why is a firefox plugin able to recognize elements Firefox is not?
  2. Is there a way to pass the source from Firebug engine to Firefox, or any other viable workaround which would enable Firefox to recognize all of the elements on the page?

My guess is that these "hidden" elements have been created by javascript after the page load, but I'm not really sure.

I'd say Firebug is displaying what's in the DOM (ie what is in the page at the instant you are looking at it) , while View Source is displaing the source that has been received from the server (ie what is in the page at the first instant it's displayed) .

If you want to see the "source" from the DOM, maybe the Web Developper Toolbar Extension can help : from what I remember, it provides a "view generated source" option.

For No.2

Open Any Page, and Press Ctrl+A or Select All, and right click, click View Selection Source , You should able to see any html nodes as you see in Firebug.

Your guess is correct. "View source" reveals exactly what the server has passed down to the client. What Firebug shows you is the "rendered source code", which is taking the current DOM state, and rendering it back into a HTML representation, that may or may not look very much like the actual HTML code written.

Your question is unclear.

The View Source command displays the raw HTML that was downloaded from the server.

Firebug's HTML tab shows the elements that are currently on the page.
Any changes made by Javascript will show up in Firebug (which gives a live view), but not in View Source. (Because they weren't in the HTML that was downloaded from the server)

Firefox's View Selection Source command, which appears only when some text is selected, shows the live source from the DOM and should show exactly what you see in Firebug. (Except that it won't update after you click it, so if the DOM changes again, you'll need to click it again to see the change)
To see the source for the entire page, you can press Ctrl+A, then right-click and click View Selection Source.

If theis doesn't answer your question, please elaborate.

Firefox shows the source code as it comes from the server, any alterations to it via JavaScript will not show up. Firebug keeps track of the changes to the document and updates the source code.

Doing Ctrl-U or View | Source will just give you the static HTML document that is returned by the server.

What you probably want to look at - and what you are seeing in Firebug - is the rendered DOM. If you install a Firefox addin such as Web Developer you will be able to view the rendered DOM - ie the HTML dynamically rendered in javascript and the actual document the renders in the browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM