Links with relative path in <iframe> doesn't work based on the loaded html file location

163 Views Asked by At

Now I am running web app at https://example.com

And there, I am gonna open the html file from my "PC - local file system" and render its content in iframe.

But the file-content contains links with relative path such as <script src="1.js"></script> and it tried to find https://example.com/1.js

Is there any way to make it find the 1.js based on my local file location?

So here's the example

My folder structure is like below

Directory1
   Html1.html
   Js1.js

And at "https://example.com", I open the "Html1.html" and render its content in <iframe> tag
The "Html1.html" has "<script src="Js1.js"></script>" in it.
Now it finds "https://example.com/Js1.js" instead of the local file.

So I tried to get the absolute path of the local file when opening it in the browser, but couldn't.

0

There are 0 best solutions below