I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
You can use any of these JavaScript commands in the Chrome DevTools console to get the HTML of the current page: 1. Simple one-liner to get all HTML:
1 | document.documentElement.outerHTML |
1 | copy(document.documentElement.outerHTML) |
1 | document.querySelector('html').outerHTML |
1 2 3 | var html = document.documentElement.outerHTML; var formatHtml = html.replace(/</g, '\n<'); copy(formatHtml); |
Testing if the previous output contains the string outerHTML
: True
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
You can use any of these methods in the Chrome DevTools console to get the HTML of the current page: 1. Simplest method:
1 | document.documentElement.outerHTML |
1 | copy(document.documentElement.outerHTML) |
1 | document.getElementsByTagName('html')[0].outerHTML |
1 2 3 | var html = document.documentElement.outerHTML; var formatted = html.replace(/></g,'>\n<'); console.log(formatted); |
Testing if the previous output contains the string outerHTML
: True
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
You can use any of these JavaScript commands in the Chrome DevTools console to get the HTML of the current page: 1. Simplest method (gets formatted HTML):
1 | document.documentElement.outerHTML |
1 | document.querySelector('html').outerHTML |
1 | copy(document.documentElement.outerHTML) |
Testing if the previous output contains the string outerHTML
: True
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
You can use any of these JavaScript commands in the Chrome DevTools console to get the HTML of the current page: 1. Simple one-liner to get all HTML:
1 | document.documentElement.outerHTML |
1 | copy(document.documentElement.outerHTML) |
1 | document.getElementsByTagName('html')[0].outerHTML |
1 | let pageHtml = document.documentElement.outerHTML |
1 2 3 4 5 6 7 | let htmlContent = document.documentElement.outerHTML; let blob = new Blob([htmlContent], { type: 'text/html' }); let url = window.URL.createObjectURL(blob); let a = document.createElement('a'); a.href = url; a.download = 'page.html'; a.click(); |
Testing if the previous output contains the string outerHTML
: True
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
I have a webpage that's open in a chrome browser but the page no longer exists. What javascript should I type in the console to get a copy of the entire page html?
You can use any of these methods in the Chrome DevTools console to get the HTML of the current page: 1. Simplest method:
1 | document.documentElement.outerHTML |
1 | copy(document.documentElement.outerHTML) |
1 2 3 | var html = document.documentElement.outerHTML; var formatted = html.replace(/></g, '>\n<'); console.log(formatted); |
1 2 3 4 5 6 | var html = document.documentElement.outerHTML; var blob = new Blob([html], {type: 'text/html'}); var a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'page.html'; a.click(); |
Testing if the previous output contains the string outerHTML
: True