简体   繁体   中英

Get page source code

I am at work and we use Internet Explorer 8 with some security. Normally if I needed to get source code I would simply right click, view source, but I see no option for that on the right click menu.

The browser does allow code in the address bar so I came up with this

javascript:alert(document.body.innerHTML)

However this present problem if the page is very large, as you cannot scroll the Internet Explorer alert box. What would be a snippet I could use to display page source code, that is scrollable?

Note it shouldnt matter whether it is the "original" source or the "rendered" source, but if you have both options that would be nice.

Prepare your snippet in jsFiddle!

http://jsfiddle.net

For example you could create a pre element, append it to document and set text to the document's source!

var head = document.head.innerHTML;
var body = document.body.innerHTML;
var element = document.createElement("pre");
element.innerText = "<html><head>" + head + "</head><body>" + body + "</body></html>";
document.body.appendChild(element);

Now remove all line-breaks, copy and paste it into address bar and run! It's tested ;)

javascript: var head = document.head.innerHTML; var body = document.body.innerHTML; var element = document.createElement("pre"); element.innerText = "<html><head>" + head + "</head><body>" + body + "</body></html>"; document.body.appendChild(element);

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