Sometimes I like to play around with source codes of other websites, such as google.com
. I simply copy-and-paste the code I get from typing view-source:google.com
in my web browser and put it in an html file. However, if I have an image pointing to /favicon.ico
instead of http://google.com/favicon.ico
, it won’t load since it looks for favicon.ico
on my computer instead of at google.com
. The same applies for all sorts of other html elements and AJAX requests. So, is there some magical way to change where "/" points to?
2
Answers
Well, since changing where "/" points to in
XMLHTTPRequest
andfetch
would violate CORS, this is not possible with AJAX requests.You can achieve that by adding a base to your
head
tag:Source