Is there a way to track user navigation inside iframe - javascript

I wanted to know the url the user visited inside a iframe tag
I know it need same origin policy doesn't allows it
Is there a way to achieve this?
For eg: I have a website inside which I used ifame to show another website I wanted to know what pages of another website user visits inside iframe tag website

Related

Render dynamic content in iframe base on parent

I want to display my website in iframe of other domain(s). When displayed in iframe of that domain, I want to perform some actions like hiding/displaying content. Pages from my website are also iframed in same domain as well. So there is dynamic behavior. How do I find out where is my page iframed? There will be navigations from one page to another in iframe and whenever full page load happens, I want to know the context/parent where my page is iframed.
Using postMessage is not an option because it is async and I don't have control over other domains/apps. I found out iframe name can be accessed from following question -
access iframe name from inside iframe
Can I use it to find out the iframe context. (I can ask other domains/apps to set particular name to iframe so that they get correct rendering of the page)

How to know if iframe is blocked?

Some website don't allow you to view their website in an iframe. I would like to know what code I could use to identify this and redirect to another page in this situation.

How to redirect to parent window after logging in from iframe window?

I am using an Iframe window to display the login form of another website. And what I want is the user should go to that particular site after logging in(even if logging in fails, any click on any link in that iframe should take the user to that site in the full window(parent window).
As long as the links (within the iFrame) are part of the other page, you can't "hijack" their target. You would have to have the means and ability to modify the target attribute of each link to point to _parent or use javascript to reference the window.parent.
Based on what you're saying (you're logging in to a different domain and the page is not part of your site) this wouldn't be possible without implementing some kind of proxy where you could modify the contents between page visits.

Facebook share from within an Iframe which directs to a Parent page

We have parent page with an Iframe in it.
We want people to use a Facebook share button (using Addthis.com) within the iframe, and that the share will:
Get the parent page URL, and link the share to the father page
Will get the title, description and thumbnail from the iframe page
I understand Facebook Open Graph can help but dont know how.

Retrieve URL from iframe using window.postMessage

I'm trying to access the URL of an iFrame that I open on my site. The iFrame is from another domain so traditional methods violate the same origin policy and are flagged as cross site scripting. However, I just discovered window.postMessage, but I don't quite know how to pull it all together.
My goal is to capture the final URL in the iFrame. For example, a user clicks a button on my site to open an iFrame. Say that iFrame loads a web site and the user clicks around on the site. When they close the iFrame, I want to capture the URL so the next time they click the button on my site, I can open the iFrame to the same state that the site was in last time they visited. Is this possible with window.postMessage?
Thanks!
document.iframe[name].src
document.iframe[name].document.location.href

Categories

Resources