Is it possible to open a pop up in an iframe - javascript

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.

Related

How to prevent an iframe from opening new tabs?

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.

How do I detect the Google+ "share task complete" in Javascript and close Chrome Bookmarklet?

I'm using a bookmarklet that lets me share the current URL on Google Plus.
Here's the JavaScript:
javascript:(function(){var w=480;var h=380;var x=Number((window.screen.width-w)/2);
var y=Number((window.screen.height-h)/2);
window.open('https://plusone.google.com/_/+1/confirm?hl=en&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'','width='+w+',height='+h+',left='+x+',top='+y+',scrollbars=no');})();
Is there a way to detect the "Sharing Successful" event and call a window.close()? And where do I call it in this JS? Even a pointer in this direction will be appreciated.
Is there a way to detect the "Sharing Successful" event and call a window.close()?
No you can't.
Browser security prevents you from using Javascript on one page to interact with another page on a different domain. This is why I can't put up a website that opens your bank's website in an iframe and then controls it.
The Javascript in a bookmarklet is considered to be part of the page that is open when you execute it. So the code becomes part of the page you are adding to Google Plus, and it can not interact with the page from Google because it is on a different domain; and vice versa. The code can open the window, but that is all.
To do what you want would require creating an add-on, extension, or user script.

Open url in new tab using javascript without click an anchor

i read a lot of solutions but all of them are clicking a url, and it works, but my client ask me to do is users opens his website, it automatically open a new tab with some special offers , so my question, is there any way to open a new tab without any user intervention? , maybe a jquery plugin?, i know the tabs rely on the web browser, but it have to be a way, a lot of web pages does it,but how?
Greetings
Without modifying the configuration of browser, the answer is no, only trusted event can open a new window (or tab)
You may ask if your client could change their browser's configuration to allow a popup window from an untrusted javascript program.
Write script in your page to open new page:
<script>
window.open("specialOffers.aspx");
</script>
and in the "specialOffers.aspx" page in the tag write:
<base target="_blank"/>

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?

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