what is the right use of window.open in IE8?
window.open('prova.php','prova','width=350,height=250');
is good in firefox but not in IE8
window.open works across browsers. And your code works fine for me in IE8 too. It could be some other reason like your pop-up is being blocked, check the settings just in case.
Check out:
Learn to Disable Internet Explorer 8’s Top 3 Most Annoying Alerts
IE8 has a native popup blocker. You have to manually enable popups. You can try NOT using window.open and instead inject html in the form of a modal in the page.
Related
Self.close() is working For IE but For Chrome and Firefox it shows that
Scripts may close only the windows that were opened by it.
And This Page will not a popup and it is not open by java script so what are the alternative way to close window by Script which is not open by it.
You simply can not close the window by script due to security reasons on chrome and firefox. But there is a workaround posted here.
That works on chrome 40 and latest version as I have tested.
chrome closing of opened window
I know it's too late to answer but none of these solution worked for me . I wrote
onclick="top.window.close();"
and it worked .
When using the below to open a new window in Chrome the window always opens maximized. In Firefox it opens at the correct 200x200 size, so how can I get Chrome to behave the same and not maximize?
gamewindow = window.open("","","width=200,height=200");
I'm now finding that if I include location=0 and menubar=0 that they still show up in both Firefox and Chrome. What's the deal with this? Is there some other way to do pop out windows because it seems window.open is unreliable.
I'm testing your example on win7 and it works fine on chrome, at least for me
Have a look at this fiddle
Are you using it on a maximized (fullscreen) window on Mac?
Btw, I would not recommend using window.open since it usually gets blocked by pop-up blocker
Edit: tested on Chrome stable, build 28.0.1500.95 m
I want to close the current tab of Internet explorer on click of 'Log Out' button. It is a new functionality to be implemented in my web application. My application supports only Internet Explorer. The page on which Logout button is located is combination of many pages of window.close() is not working.
I have used following code in vbscript to close the current window of browser for Internet Explorer:
if(window.opener = Empty) then
dim x
x = "<%=Request.Browser.MajorVersion%>"
if(x="6") then
window.parent.opener = "x"
window.parent.close
else
'I need code for closing the tab here for IE7
end if
end if
I have used "<%=Request.Browser.MajorVersion%>" to fetch the version of Internet explorer. Itf it is IE6 then code works fine because there is no tab functionality in IE6 but how to close the current tab for IE7. Please help me out in this context so that I may close the current tab for IE7 also. Thnaks in advance!
You can try this to close the tab in IE7:-
window.parent.opener = "x"
window.parent.close
I have faced the same issue and found that this was working fine for me. Although this would give you an extra message(Microsoft warning message):-
Modern day browsers will not allow you to close a window or tab that you have not created with window.open. Any ways of doing it to make it work is a HACK and is bound to break when browsers are upgraded.
What are situation when you want to use window.showModalDialog function? It seams that you can do exactly the same with window.open function and few parameters that remove some of the chrome (navigation, addressbar, etc...)
When would you want to use window.showModalDialog and window.open?
It has been a few years since this question was originally asked and things have changed a bit since then. window.showModalDialog is now officially standardized as part of HTML5 and is supported in IE, Firefox 3+, Chrome (albeit buggy), and Safari 5.1+.
Unfortunately window.showModalDialog is still plagued by a number of issues.
Modal dialogs are blocked as popups by default in Firefox, Chrome, and Safari.
The modal dialogs in Chrome are buggy and aren't truly modal - see http://code.google.com/p/chromium/issues/detail?id=16045 & http://code.google.com/p/chromium/issues/detail?id=42939.
All browsers except Chrome block the user from interacting with the entire window (favorites, browser controls, other tabs, etc...) when a modal dialog is up.
They're a pain to debug because they halt JavaScript execution in the parent window while waiting for the modal dialog to complete.
No mobile browsers support window.showModalDialog.
Therefore it's still not a good idea to use window.showModalDialog. If you need the window opened to be modal (i.e. the user cannot interact with the rest of the page until they deal with the dialog) I would suggest using jQuery UI's dialog plugin.
window.open will work for non modal windows but I would stick with jQuery UI's dialog because opening new windows tends to annoy users.
If you're interested I write about this in more detail on my blog - http://tjvantoll.com/2012/05/02/showmodaldialog-what-it-is-and-why-you-should-never-use-it/.
Modal dialogs are dialogs that once opened by the parent, do not allow you to focus on the parent until the dialog is closed.
One could use a modal dialog for a login form, edit form, etc where you want to have a popup for user interaction but not allow the user to return to the window that opened the popup.
As a side note, I believe only Internet Explorer implementes window.showModalDialog, so that kind of limits your usage of it.
showModalDialog() is currently being standardized as part of HTML5. The third argument (for additional options) is not present in the HTML5 version, and is (safely) ignored by Safari and Chrome.
http://dev.w3.org/html5/spec//user-prompts.html#dialogs-implemented-using-separate-documents
Note that there's a bug in Chrome 2 which prevents showModalDialog() from loading properly. The popup window appears, but the content never loads.
One more reason to avoid using showModalDialog().
showModalDialog()works well in Internet Explorer, Firefox (3 and above)
Works in Chrome but popup is not model (you can go to parent window)
Note that while you can show modal from any popup window, you cannot use window.open from a model dialog in some browsers (IE, Safari).
Is it possible to close parent window in Firefox 2.0 using JavaScript. I have a parent page which opens another window, i need to close the parent window after say 10 seconds.
I have tried Firefox tweaks "dom.allow_scripts_to_close_windows", tried delay but nothing seems to work.
Any help will be really appreciated.
Thanks
Using only the opener object may not always close the parent window, for security reasons.
What you can do is:
On parent, have a function named closeWindowFromChild():
function closeWindowFromChild()
{
this.window.close();
}
On child, when you want to close the window:
function closeParentWindow()
{
opener.closeWindowFromChild();
}
And this should work fine. :-D
Scissored from quirksmode (EDIT: added a bit of context, as suggested by Diodeus):
Theoretically
opener.close()
should be the code from the popup: close the window that has opened this popup.
However, in some browsers it is not allowed to automatically close windows that have not been opened by JavaScript. The line above works fine in Explorer on Mac, Mozilla, Opera and OmniWeb, but not in Explorer on Windows, Netscape 4 and lower and iCab. In these browsers the user is asked to confirm the closing of the window. As to Safari, it does absolutely nothing.
Rather to my surprise it's very easy to get around this confirm box in Explorer 5.5 and 6 on Windows. Explorer merely looks if the page has an opener. If it doesn't the window has been opened by the user and may not be closed without a confirm. So what we need to do is trick Explorer into thinking the opening page has an opener:
opener.opener = top; // or whatever, as long as opener.opener has a value;
opener.close()
This trick doesn't work in Netscape 4 and lower and iCab, these browsers have more sophisticated ways to determine whether a window has been opened by JavaScript.
Generally, you can't close a window which you didn't open yourself using javascript.