Determining what is shown in an iframe [duplicate] - javascript

This question already has answers here:
Get current URL from IFRAME
(8 answers)
Closed 9 years ago.
I created a web browser type application using a textbox as an address bar and an iframe as a web content host. Upon entering an address in the textbox, the content in the iframe changes and is working properly. When the client clicks on a link in the iframe, the text in the address bar should change according to the content in the iframe - how can I do this?
For example: To begin with, www.microsoft.com is in the textbox and the corresponding page is in the iframe. If I click on a link such as products, the text box text should change to the page in the iframe.

You can use the onload event on your iframe to know when url has been changed. Then read the src attribute and update your textbox.

Related

What causes 'Are you sure you want to leave this page' in an iframe/webpage? [duplicate]

This question already has answers here:
Warn user before leaving web page with unsaved changes
(17 answers)
Closed 3 years ago.
In my webapplication, I have a certain webpage that has an iframe inside of it with a certain source (can't tell which one, but I think (?) not really important for this question), but as soon as the webpage on my webapplication that contains the iframe in it is loaded, it throws a pop up which asks if I want to leave the page. I don't want this, I want to stay on the page with the iframe element inside of it.
The weird thing is, that when I for instance use http://example.org as the source (for testing), it shows the webpage normally without any pop up (and so did other pages I tested that contained HTML, CSS and most importantly JS).
What is it that causes this pop up? The pop up does not appear when I manually open the webpage that is included as the source of the iframe, in a browser.
You get that message if the page you're trying to leave has added a listener for the beforeunload event.
The "certain webpage" may have code that's redirecting itself. Maybe it checks whether it's in an iframe and does this, so it only happens when you try to load that page in your iframe, not when you load it normally. It's hard to be more specific without knowing what the webpage is and how it's written.
There are serveral rules of iframe any page or website in your webpage. If it is not Same-origin it will allow you to iframe that website, if it is on different origin it will not allow you to iframe that webpage. For more information refer this link https://code.google.com/archive/p/browsersec/wikis/Part2.wiki#Origin_inheritance_rules

Make the link visible when hovering a non-link element [duplicate]

This question already has answers here:
How to display text in the browser status bar?
(6 answers)
Closed 6 years ago.
You know when you hover a < a> element and the link appears in the bottom left corner of the browser?
Is it possible to do it with another tag?
No. Setting the status bar manually has been disabled in modern browsers for security reasons. A malicious site developer could make the status bar display a different URL than the one they would be taken to on a link.
The Javascript property used to work like this:
window.status = "Status bar text";
This no longer does anything at all by default on any current browser.
No, but you can put an <a> element over/around another element and 'disable' the link (onclick) using javascript to achieve a similar result:
<a href="//Message in the status bar!" onclick="return false">
<div>
This div shows something in the status bar
but is actually surrounded by a disabled link
</div>
</a>

Is it possible to check for the id of the parent iframe? [duplicate]

This question already has answers here:
Access elements of parent window from iframe
(4 answers)
Closed 9 years ago.
Let's say that I've got a page in an iframe.
So...
top page {
iframed page{
}
}
Now, I want to give the iframe page an id.
From within the code on the iframed page, can I check to see if the value of the id of the iframed page is equal to something?
if ($('#iframeid', window.parent.document))
doesn't seem to work.
If it's Chrome or Firefox, you should be able to do:
window.frameElement.id
inside the iframe to get the id of the iframe itself.

How can I send a data to an iframe from main page when I working another iframe? [duplicate]

This question already has answers here:
How to communicate between iframe and the parent site?
(7 answers)
Closed 8 years ago.
I have a question about data transfer on iframes as can be seen in the picture below
http://img703.imageshack.us/img703/143/qcvf.jpg
My main page has 2 iframe.
How can I send a data to textbox iframe_b from main page when I working iframe_a?
Thanks.
You can try to set the iframe's src with a hash, and detect hashChange within the iframe. $(window) bind hashchange how to check part hash changed?
If you want to set data into iframe in script directly, I remember, not so sure, if the src of iframe is a different host, you cannot, for security reason.

How to remove an certain element in iFrame [duplicate]

This question already has answers here:
How can I access the contents of an iframe with JavaScript/jQuery?
(15 answers)
Closed 5 years ago.
I've got a website which has a iFrame in it. The iFrame is linked to an external page. I want to remove some elements in the external website (the website has HTML coding) using Javascript (other methods OK too) WITHOUT anyone clicking on any "remove" buttons or do anything, so it should AUTOMATICALLY remove that element when my webpage and the iframe loads, no one can see it.
For example, I want to remove a website's logo and some contents. I've tried lots of methods but they don't work in iFrame.
Unfortunately you cannot access elements in an Iframe if the Iframe is linked to an external site, there is no workaround using javascript.

Categories