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.
At the proxy end insert this tag:
<base href="http://pathtooriginalpage" />
and that should do it.
Related
i have react website embedded inside html page using embed tag. My react website needs a value stored in a local storage of html page.How can i make it possible?
I am trying to create a new page and manually set its content. Because the url of a blank page with injected code is still about:blank, all of the relative links on the page are broken. Is there a way to set the url of the page without actually navigating to that url via goto?
I can think of two options:
Create a function to turn a relative path into a file:// URL.
Run a simple server. I wrote a post about that on my blog
I was working on tag and let say my domain was www.abc.com. If I use href="http://example.com" it does properly navigate to intended url. However if I use href="www.example.com" it doesn't navigate to intended url.
not properly navigate
properly navigate
properly navigate
I was reading the anchor specs in https://html.spec.whatwg.org, unfortunately could not find this specific case.
The browser must know if you want to link to another website or a different file/page of your own website. The browser always asumes that you want to link to a file on your own server if you do not specifiy the protocol.
In fact: The only reason you can leave the protocol out when typing a url into the addressbar of your browser is because the browser just asumes that you want to use the http-protocol. This is not possbile with urls inside the A tag.
If you don't specify an absolute url it will think it's a route inside your site.
Possible values using href attributes:
An absolute URL - points to another web site (like href="http://www.example.com/default.htm")
A relative URL - points to a file within a web site (like href="default.htm")
Link to an element with a specified id within the page (like href="#top")
Other protocols (like https://, ftp://, mailto:, file:, etc..)
A script (like href="javascript:alert('Hello');")
Because When you click on it.. Your Browser Will suppose he need to find this link in the same file extension.
Example: if your html file extension is e://tst.html
when click on tag at Browser it will go to e:// and search about file with name "www.google.com" and not find it..
Use not properly navigate to inform Browser you need to navigate to Another website
I have an ASP.NET web app with a standard default.aspx, from within which I need to load a html page from another site (all internal intranet) and pre-populate form input controls on that loaded html page using ASP variables. Specifically, username / pwd on a login form based user details loaded by the aspx from a db. The html page also contains a considerable amount of js (shouldn't directly impact this question though).
Not sure of the best route to approach this. I have considered:
1. Loading the html page in a frame, then somehow manipulating it's DOM from another frame loaded from the aspx.
2. Loading the html during aspx page load or render, then replacing the relevant sections of the html with the new values.
I have had a stab at both approaches and ran into issues. With (2) the resulting HTML isn't recognized as HTML by the browser at all (despite the written response being just the original html relayed from the original site). I can see the HTML source in the browser, but the page itself appears blank.
Answers warmly anticipated. Thank-you.
1.if you want to go wityh iframe
You can easily modify values from communicate between parent window and iframe
from parent to iframe function
document.querySelector('iframe').contentWindow.ChildFunction(33);
from chhild to parentfunction
parent.parentfunction("4rom child")
make a function in iframe that accept an object (from parent) and populate it in.
make a function in parent that accept an object (from child) .
2.how are you "Loading the html during aspx page load or render,"
- ajax or something else?
-making a user controll
both should work fine .
( could you tell how are you loading html ?)(as it should have worked)
In FireBug the HTML view displays the full html of the page including the html of the iFrames. Is there a way to save this same html view or using another FF extension to save the full html? Meaning the saved file will have the html, body and the rest of the dom for the iFrames. I know I can view and save the individual iFrames' HTML but I want everything in a single file.
You can crawl the DOM for all the iframes and then do httpRequest to capture the dom from each url in the src attribute of the iframe.