Search code examples
javascriptstringobjectdomdocument

how can i inspect(document.body) in js while loading the page using object?


i tried to load the page using XMLHttpRequest() but i got

blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource

so i tried to load the page using something else so i used

object type="text/html" data="http://page/"></object>

it loaded the page in a small box . so i tried to define the page code to a constant so i be able to find a value from it's code using

let str = document.querySelector("body")

but it selected my page body not the page loaded using object . i tried the querySelector because

document.documentElement.innerHTML

have the same problem. if there a way to inspect elements to the correct page it would solve this . the page and console before inspecting the wanted area manually

enter image description here

the page and console after inspecting the wanted area manually

enter image description here

note: i can't edit the requested page


Solution

  • You can't because objects ( Iframses ) have the cross domain policy too