skip to Main Content

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


  1. Chosen as BEST ANSWER

    Well, since changing where "/" points to in XMLHTTPRequest and fetch would violate CORS, this is not possible with AJAX requests.


  2. You can achieve that by adding a base to your head tag:

    <base href="https://example.com" target="_blank"/>
    

    Source

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search