$window to open multiple links blocked by pop up - javascript

How to use Angular's $window to open multiple links at once? The browser seem to block the pop up, is there anywhere to overcome that issue?
http://plnkr.co/edit/m8m2I9dqE2kF1H1nzxJT?p=preview
$scope.links = [
{'link':'www.google.com'},
{'link':'www.yahoo.com'},
{'link':'www.bing.com'}
];

So yes. The problem is that the windows are being opened to another domain -- so the browser will block the windows. The solution is to open the window at a page in your domain, and pass the url you want to go to and then have that page redirect to the page.
http://plnkr.co/edit/nAfQ4oHyCC22oSCFqMpH?p=info

This is not an issue. After dark days when spammers used popups for displaying advertisements, window.open() is blocked.
Pleas read
Allow window.open to open new window and not popup
Open page in new window without popup blocking

Related

Why doesn't window.open(url, name) open in the SAME window with IE11?

The problem is when calling window.open(url, name) for a specific page, it is always opened in a new window, instead of the SAME one. In other words, every time this statement is executed, a new window is opened, while what I want is only ONE new window is opened and all the following calls will open the page in that new window. The name parameter in this javascript statement doesn't work for this case obviously. It only happens with IE11(Couldn't try other versions of IE).
When I tried opening window of my own pages, it worked as expected. But that specific page doesn't. That page is on the same host but out of my control. I don't know what exactly it does. The only thing I know is it relaxes document.domain. But even if I change the domain of the main page to be the same as that page's, it still doesn't work.
Does anybody know what's the root cause?
Thanks in advance!
The problem might be due to Internet Explorer settings.
Under Internet Options
Click Settings under Tabs
Under When a pop-up is encountered:, select Always open pop-ups in a
new tab
Under Open links form other programs in:, select A new tab in the
current window
to do that you want
window.location not open
open will open a new window/tab
EG
window.location = "http://www.google.com"
to navigate to google.com in the same window/tab

how to open web application in a browser without navigation buttons

I have a web application, and I want to disable the Back button.
I read and found that I can open the browser without the navigation controls with the function window.open(...).
This is the code:
window.open (mywebappURL,"mywindow","status=1,toolbar=0");
I tried to put it in my Main.Master page, but I get an infinite loop and the new window is opened as a popup window of my application.
Does anyone knows where should I put this code to get my web application opened in a browser without navigation buttons?
Thanks,
Inbal.
try this on the link's onclick() event
function openPopup(){
var pathname = (window.location.pathname);
window.open(pathname+'somePopup.html','','width=800,height=450,resizable=yes,dependent,screenx=80,screeny=80,left=80,top=20,scrollbars=no');
return false;
}
and in the html
click me
To answer your question directly, make sure the window you're opening is a different URL than the window that's initially visited. So your visitor might arrive at www.example.com/index.html which then opens www.example.com/popup.html
If you open index.html again, the new copy will immediately open a popup, which will immediately open a popup, and there's your infinite loop.
However, as several people have commented already, this is generally discouraged. Among other disadvantages to this approach, popup blockers will likely interpret this as trying to launch a popup advertisement, forcing your visitors to recognize what's happened and change their settings.

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"/>

window.opener is useless after a redirect in the popup window (JavaScript)

I'm building an app that involves authentication via third-party. To make the process not redirect the actual app I open a new window that then does the authentication and returns to main window after success.
This doesn't, however, go as well as planned. When the popup redirects to third-party and back, window.opener gets null. It's still possible to close the popup by window.close() but I also need to refresh the logged-in-area in the main window, like this:
window.opener.check_auth_status();
I really hope there is a way to fix this, e.g. binding a function to popup-close in the main window? Refreshing the whole page would be highly unnecessary.
One way is to set an interval to main window checking if the popup is closed, but this seems so fiddly.
You have a few options that may or may not work in the latest versions of the browsers due to security updates
1) check that the window is closed from the opener - not fiddly and actually the safest
2) give the opener a name
window.name="myMainWindow";
and in popup (script from SAME domain) - should normally not open a new window or change content
var handle = window.open("","myMainWindow");
handle.check_auth_status();
3) use an iFrame in the popup and when you want to access the opener, use top.opener

Will it be possible to do window self-closing on the other site

I have a site let say http://myownsite.com and I want to run a script to open new window on Safari or any browser in which I don't own that site http://theothersite.com
if I don't have a control with that site would it be possible to do self-closing??
like make it popup for 3 seconds and close after that
I was using iframe to open the page inside my page but iframe can not receive the cookie on cross-domain...
You can't run javascript on a different domain. Same cross-domain security issues you have seen with cookies.
If you open the window in javascript, you can get the window handle and close it in the same code:
var win = window.open(url, options);
// wait
win.close();
I'm afraid I can't find a reference right now, but no. It's not possible. JavaScript only has permission to operate on the window or tab it is running in. JavaScript has no knowledge of what other windows or tabs are open in the browser. That window can only be closed by JavaScript running within that window.

Categories

Resources