Is there any possible way (html, js, jquery) to change the base URL path of an iframe
?
Here's what I'm trying to do: I have a webpage that has a URL-entry field and a display area. The web app takes whatever URL the user enters, and then uses a special proxy service to retrieve the webpage that the user has specified. I then render this webpage in the display area using an iframe, where I insert the html source code into the DOM
of the iframe
. I do not use the src
attribute because I am trying to demonstrate the functionality of my proxy service, and I don't want the browser to directly render the page itself.
The html source that I insert will load in the iframe, with one caveat. None of the images or other resources that use a relative pathname work because they reference the URL of my outer webpage as the base URL. For example, if my webpage is located at www.me.com
and the user tries to load www.google.com
, I can render the html
source for www.google.com
, but the main Google image does not load because the image tries to load from www.me.com/image
rather than www.google.com/image
.
An iFrame, also knowns as Inline Frame, is an element that loads another HTML element inside of a web page. They are commonly used to embed specific content like external ads, videos, tags, or other interactive elements into the page.
The URL found in the address bar of the front page of a website is its base URL. In other words, the common prefix found while navigating inside a given website is known as the base URL. One can select a base URL from the list of those available with help of the URL general properties page.
At the proxy end insert this tag:
<base href="http://pathtooriginalpage" />
and that should do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With