How to prevent an iframe from opening new tabs? - javascript

I'm trying to embed a Behance page into my website via iframe, but when the page is loaded, Behance opens 3 new tabs asking to sign in looks pretty awful:
Can I disallow this functionality? It doesn't even ask me, just opens these tabs. Some browsers that I tested block popups by default, but maybe I can set it manually to block them every time everywhere?

The iframe element has a 'sandbox' attribute, which allows you to restrict the behavior of the iframe.
Checkout the detail: MDN, see the part of allow-popups.

Related

Is it possible to open a pop up in an iframe

Is it possible to force a pop up to open in an iframe where the action to open the pop up has taken place?
I have a VueJs Application that displays a website inside an iframe and don't want the application to open new windows. But it is also not acceptable to just block all the popups with sand boxing, as some contain critical functionality.
Thus i am looking for any way to "force" target="_blank" onto the link on the webpage.
I know that there is no standard way to do so, but would be open for any suggestion on how to alternatively solve this.
Maybe there is a way to disable the browsers ability to open new windows and hijack the calls.
Looking forward to your answers.
That capability is all or nothing, mostly. Since it's a different site in the iframe, you likely don't have access to the iframe content and so can't control the links in it.
iframe has a sandbox attribute to which you could add the allow-popups option
allow-popups: Allows popups (such as window.open(), target="_blank", or showModalDialog()). If this keyword is not used, the popup will silently fail to open.
As in:
<iframe ... sandbox="allow-popups"></iframe>
There's also:
allow-popups-to-escape-sandbox: Lets the sandboxed document open new windows without those windows inheriting the sandboxing. For example, this can safely sandbox an advertisement without forcing the same restrictions upon the page the ad links to.
allow-modals: Lets the resource open modal windows.

chrome extension opens with page load

I need to create a chrome extension that for every web page te he user opens - he will have a button on top of the page (similar to the google translate extension - just that it will appear with page load, without the need to press a button) - preessing on it will do some activity.
from what i saw - the way to do it is to create a content script that will add an iframe that includes the button on the window.onload. just before i do that - i want to be sure there is no more simple way of doing that.
Thanks.
There is an experimental infobar API, but it's unknown when, if ever, it becomes stable.
As-is, you really need to inject your UI into the page DOM from a content script, with an iframe being a good solution to separate your UI from the page.
If it's just a button for each page then you could use a Browser Action
If you'd like for it to actually be in the page then an iframe is a good way to go.

disable certain navigation links in popup window (external website)

Hi I am opening an external website in my pop window. I would like to disable certain links in that popup.
i.e. I am opening http://www.yahoo.com in pop and I want to disable some links in that pop-up so that who ever visit yahoo.com using my website, will not able to click on some links...
Is it possible? any idea?
It is impossible to run JavaScript on another domain because of the same origin policy. imagine someone opening up your bank account in a new window/frame and altering the links to transfer money to their account. ;)
You can screen scrape the content with your server and redisplay it, but you have to worry about proxying all of the relative links.
If you are creating a popup using the standard window.open you can manipulate the DOM of that document. See here for more information on how to do that (towards the bottom of the page). But this is fairly limiting to writing stuff to that page. I suppose you could render the link in an iframe and inject some javascript to manipulate it?

javascript and iframe

In my website I use an iframe to show an external content but there is a popup window in it.
I can/do block popups in my site but not inside the iframe, is there a way to disable a specific (or all) javascript from an iframe?
There is an Internet Explorer specific way to disable scripts in a frame, but nothing general.
You really should negotiate with the owner of the document that you are reusing.

Change Default Action of IFRAME Hyperlink Clicks

I'm using Google search in a page, and it shows up in an IFRAME. However, when you click on a link in the search, it's leaving my site and redirecting to that other site. Is there a way to intercept that call with jQuery and make it open that link in a new window, instead?
Due to security reasons, what you can do with an iframe is very limited (In cases where you frame another domain).
The way this is implemented varies a bit from browser to browsers but most browsers won't let you manipulate the data in the iframe.
To my knowledge this isn't possible, assuming you are refering to an implementation of http://www.google.com/cse/

Categories

Resources