new window/tab event from an <iframe> - javascript

I have an iframe in my website which its content is dynamic and I can't control it.
Is it possible to detect a new-window/tab opened from this iframe using Javascript?
Thanks!

You could do this, but in some weird way :)
If you can edit html on the server where iframe source loads from, place there another iframe (style="width:0px;height:0px;display:none") with src="http://your site/control page".
This trick will give you DOMdocument control by js on the both side of iframe.

Related

How jquery or javascript access DOM in iframe?

I want jquery or javascript to access DOM in Iframe.
For example, I make a iframe to show amazon.
then I wanna get a banner image link on amazon.
Can I do this?
and I have one more problem.
if I click amazon banner that is made a by _blank target on "a" Tag in a iframe,
browser make a new tab. but I wanna see a new page in a iframe.
You cannot do that if the origin of the iframe is different from the parent document :
https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy

Open links from an external website that sits in an Iframe in a new window

I have a website with an iframe on one page that goes to an external URL (which I have no control over). I am trying to find a way to have all the links in the Iframe (not the entire page) open in a new window. I've tried a couple solutions with no luck. Is there a way I can target the iframe and use the HTML base tag?
Due to the Same Origin Policy, you can only modify the contents of an iframe if the domains and protocols match.

What are the benefits of not using an iframe to embed one site in another?

I was studying how Disqus and other embedded wigets are implemented, and I came to realize that they don't use an enclosing iframe where all their widget is run. What they do is to append elements dynamically to the embedding page through JavaScipt and then run almost every form or button in some iframe. What's the point of doing this? Couldn't they just wrap everything in an iframe and then change the parent window URL (to allow navigation) through some kind of cross-domain messaging system such as easyXDM? Can anybody point out some benefits that arise from having some elements not inside an iframe?
Code inside an iframe may not be able to set cookies as browser thinks it is an advertisement.
Iframe content cannot control the size of the outside iframe, so iframe needs to be created with javascript and javascript needs to be loaded externally so that external site has total over iframe size.

Communicate with iFrame code (Chrome Extension)

Happy new year :)
I have a Chrome extension which is a popup that contains an iframe, inside that iframe i load a whole web app. my question is
How can i communicate with the code inside that iframe form popup.html or from the background page? I would need to either read DOM elements inside that iframe or better be able to make js calls to different methods.
Thanks for all the help!
Use a content script that loads inside that frame. They can access the DOM of that page and make calls to the background page, though it's a bit harder to be able to communicate with the JavaScript on that page - but DOM elements should be fine if you control both the iframe and the extension.
See http://code.google.com/chrome/extensions/content_scripts.html

prevent html page from open a new window

I have a html based application and sometimes my html app needs to open another url in iframe.
the problem is that the third party url in the iframe open a new window too with the same content, the same url.
so how can i prevent it?
This seems like an iframe breakoutscript in the thirdparty page. A few links about a solution to this problem.
http://stuntsnippets.com/prevent-iframe-breakout/
http://www.zimbio.com/Web+Design/articles/1110/How+prevent+iFrame+breakaway
How to prevent IFRAME from redirecting top-level window

Categories

Resources