In my webapp I work with new Tabs I open with window.open. Sometimes, a tab with the target-name is already open in the background and the window.open(..., "sametarget") only reloads it, which is fine - but the Tab stays in the background after reloading, which is not. Is there any way (JavaScript? window.open parameter?) to get it to the foreground after reloading? Or is this prohibited by browser security?
I am trying this in IE7 / IE8.
Does window.focus() solve your problem?
EDIT
Possibly not: Possible to set tab focus in IE7 from JavaScript
Related
I have a twitter sign in, it's known that Google and Facebook have their own script for opening sign in popup and it somehow works even on Safari, but twitter doesn't. So we implemented our own, the issue we face is that IOS devices are blocking popup opened with:
window.open(url, '_blank', 'height=400,width=800,left=250,top=100,resizable=yes', true);
I've also tried creating an anchor tag after reading (Bypassing popup blocker in safari):
<a id="js__twitter__popup-link" target="_blank" style="visibility: hidden;"></a>
Then we add url to href this.twitterPopupLink.setAttribute('href', url), then document.querySelector("#js__twitter__popup-link").click(), but on IOS it won't open a new page even that way.
Tester said that on iPad popup is opened but using IOS emulators it didn't open for me on iPad. It's a sure thing that it doesn't open popup on iPhone through.
on IOS it won't open a new page even that way
Correct. The point of a popup blocker is to prevent popups. Any workaround you can imagine they've probably also imagined and prevented.
In general, you can only open a popup window in one scenario - immediately after a user-initiated click. Triggering a click via JavaScript won't bypass this.
Example of what I mean:
http://jsfiddle.net/dtipson/ttebddd5/2/
In all other browsers, and in cases not linking to twitter's intents pages, when you open a new window or target blank, it opens in a new tab. But with android, even once you've set the browser to handle links to twitter.com, the new window opens, then immediately closes, and then the original (calling) page navigates to twitter.com. Example code that won't work properly (though I doubt it's anything to do with this):
window.open(
'https://twitter.com/intent/tweet?text=hi',
'intent',
'scrollbars=yes,resizable=yes,toolbar=no,location=yes,status=no,width=550,height=420');
My guess is that this has something to do with have Android handles "application intents": if a page redirects to something that claims to have a native application link, it looks back up the chain of window.opener and affects the original page instead.
To try and block this behavior, I've tried using window.open to open a page that waits a few seconds and THEN redirects to twitter.com/intents. But even here, the new tab opens, waits for however many seconds on that transition page, and then right when it redirects, it closes itself and the original tab redirects to twitter.com instead. I've tried setting window.opener to null (even though that shouldn't do anything). I'm not sure how any code on twitter.com could even affect the original page as they are obviously not on the same domain (and I've tried setting things up so that the original domain does NOT have twitter's widgets.js on it, so they can't be using POSTMessage).
This really seems to be a (imho, bad) )quirk with how Android handles intents. Anyone know of any workarounds?
I created a simple firefox add on using addon-builder that installs & successfully appears in the add on toolbar at the bottom of the browser.
If I press ctrl-n, open new tab, open new window, or open private browsing window in firefox, then I see and can use my addon. However, if another site programmatically opens a window using window.open(), then my addon doesn't appear.
Is this by design? Or is there a setting that I can include in my addon so that it always appears, even if the window was opened through window.open() instead of ctrl-n?
When sites open with window.open, they specify which parts of the browser UI will show. You may be able to place it somewhere less likely to be removed, like the navigation toolbar. The add-ons toolbar sounds like it's going away soon, anyway.
We have written a small javascript function which checks if a URL should open in same window or a popup. In cases when a url should open in a new window IE is giving some strange behaviour a window popup flashes and closes with a beep sound. Can anybody suggest whats going behind the scenes i do not think its my javascript which is wrong. Is it some browser weird behaviour.
I suspect you have a third party pop-up blocker installed.
Yep, this sounds like some third party stuff. By default IE will try to guess what it should do with popups (open in a popup window, open in a new tab, don't open at all) but it won't try to open a window and close it immediately (unless caused by some addons or code included in the page). JavaScript errors shouldn't cause the window to close either (unless they really call window.close()).
When I window.open("http://blarg") in chrome, I get a new tab. If I delay the open, say using a jquery $(hrm).animate({},5e3,function(){window.open(url)); it opens the url in a new window with no status bar, etc — if I give it permission to pop-up that is.
I'm looking for a way to get the instant behavior, that is, I wish to open a URL after an animation, but still in a new tab.
I imagine I could get by with learning a way to instruct chrome to never ever open pop-ups and to always open them in tabs (I imagine there's a webkit setting, why it's not a built in is a mystery); but I'd rather try to find a way to do it from the javascript if possible.
I somewhat doubt there's any way to do this though. I'm not aware of any javascript that's tab-aware.
A similar question was asked about tabs in Firefox, but the same answer applies:
There is no way to force a window to open as a tab. It's all dependent on the user's preference settings.