When running this script:

var myobj = document.createElement('script'); 
myobj.type = 'text/javascript';    
myobj.src = 'http://whateverpr0nsite.com';
document.getElementsByTagName("body")[0].appendChild(myobj);

In the Chrome console, I see this message as the request gets blocked by a DNS porn filter:

Resource interpreted as Script but transferred with MIME type text/html: "http://127.0.0.1:2372/blockpage?id=36".

I'm actually interested in the domain/IP address. Is there a way to access this information via JS? Or alternatively, via the myobj object?

有帮助吗?

解决方案

Short answer: NO

Resource interpreted as Script but transferred with MIME type text/html: "http://127.0.0.1:2372/blockpage?id=36"

Javascript has no control over this error message as when the tag is constructed and append to the body, the js functionality is over.

Now the browser comes across this tag and makes the http request. As it finds that the link must end with .js extension and you have just provided a domain name, it gives mime error.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top