i have this javascript
function frameURL() {
var address = document.getElementById("address");
var iframe = document.getElementById("iframe");
var frame = iframe.src;
address.value = frame;
}
and html
<input type="text" size="100%" id="address" />
<iframe src="" id="iframe" width="100%" height="100%" scrolling="auto" onload="frameURL()" ></iframe>
basically this is just like a web browser you type into the text input box and it changes the iframe src i have all that working but…
i want it so that when you click on a link in the frame the address box to automatically change to the new url. i thought the code above would do it but it doesn’t, any suggestions?
You might try setting up a timer which occasionally updates the input box with the current value of the iframe’s src attribute. I’m not sure if that attribute actually gets updated when you browse the frame, I’m thinking not, but it’s something to try and rule out.
If that doesn’t work, and the iframe points to pages on a different domain, then you can’t do it with JavaScript. JS can’t peer into the content of the frame if it’s on another domain, nor can JS in the frame affect the containing page. That’s an important security attribute of web browsers, or all kinds of phishing scams would be trivial to implement yet hard to detect for the end user.
If the pages are on the same domain, there’s probably a way…
i’ve tried a timer but it didn’t work.
by the way the browser type frame thing works and i can view different domains in the frame with no warning its just it doesn’t let me get the src value from the frame. (it lets me set it and read it but not display it.)
That’s the point. It would be a security nightmare if you could iframe the whole interwebz and track where people go.