window.open not working when attached on onload event in chrome and safari - asp.net

I have attached some javascript on onload event of the form. this script contains window.open. Although this works fine in all the browsers window.open doesn't open a new window nor it gives nay error message in google chrome and firefox.
I want to first check the screen resolution if it is less than 1024 then I would open it in a new window without menu,toolbar and others so that the user has more space to work on.

This is a feature, not a bug! :)
remember back in the '90s when pop-up windows annoyed the crap out of everyone? Well, because of the MASSIVE abuse of that JavaScript behavior, now the only way to open windows is with direct user interaction; like a click.

If you have a legitimate reason for opening another window, attach a click event to a button labeled such that it properly indicates you'll be opening a window. If your user wants to open the window, they will do so, and it will correctly get past any but the stupidest popup blockers. If they don't want to, you should not be opening a window in the first place.

Related

Misplaced button in dialog window of JqGrid, works fine while developers tools opened

The strangest behaviour occured and I can't handle it myself.
I have ASP .NET MVC application with Jqgrid version 5.1.0. Everything works fine, beside one dialog window.
In my grid I use default deletion method. There is delete button defined by $(tableHtmlId).navGrid( ... ) function. After clicking delete button, confirmation dialog window appears. This dialog has misplaced cancel button (the one on top-right corner), as shown on following screen:
I thought about editing css styles, so I hit the console button, and as soon as develpers tool window appeard, look what happened:
Everything look fine. However, when I put cursor over cancel button, it goes back to wrong:
This behaviour occurs on Chrome, Firefox and IE. This bug is too atomic for me to solve. Please help. :)

Window.Open without popup-blocker

i want to open a popup window when user leaves tab or closes browser, the available option with me was window.open, but with that, it asks for popup blocker, if it is not enabled, i tried every possible ways to ignore popup-blocker but in vain, i tried onunload, onbeforeunload, but it does not works, i also tried to use modal dialog, before the tab/browser, i used it in onbeforeunload event, but it shows a browsers alert message, which i dont want, my simple requirement is, i need a popup window (if possible) or modal dialog, on the close of tab/browser, but should ignore popup-blocker, i guess with modal dialog, i dont need to worry about popup-blocker, because that wont be the new window, but how i would be handling it, while user closes tab/browser. If any of the above option is not possible, can anyone help me with any other possible alternative, or helpful articles.
Edited Question
i used the below script and with that i can open a new popup window on link click, without popup-blocker interfering in it
$('a[href=http://www.google.com]').click(function(){
window.open(this.href);
return false;
});
then why its not possible for the closing events.
You can't - because that's what popup blockers do: they block popup windows (i.e. calls to window.open or invocations of target="_blank" links) unless it is directly in response to a user mouse action.
Opening popups when a browser window is closed was a common tactic of "pop-under" ads in the early 2000s, and it irritated users, that's why Firefox and IE6's popup blocker block them, and there is no way around it for you unless you ask the user to disable their popup blocker on your site (and I think you'll find most of them will have no idea how to do that).
What are you trying to accomplish anyway? What is the content of this popup that you want the user to see? What other approaches have you tried?
Exact duplicate of your previous question....
I'll post my answer for it here as well though...
Popup blockers are designed to prevent this behavior.
I would suggest using a modal window instead of an actual browser window. I don't think that these get blocked because they are opened within the page itself.
As for the event... You could do something like...
window.onbeforeunload = function whatever() {
//Do code here for your modal to show up.
}
If you are just trying ot give a warning or something you could do
window.onbeforeunload = function showWarning() {
returnString = 'Whatever you want your message to be....';
return returnString;
}
By returning something in the onbeforeunload statement it will show a confirm box with your message in it.
Popup blocker will not block the opening of popups if the javascript code which opens the popup is executed on user's direct action like click, keypress, drag, etc.

window.open in web application for iPad running in fullscreen replaces the existing window

I am writing a simple (ASP.NET) web application for the iPad. It is written and works well however one feature is it serving up PDF files (among others). To do this I used window.open to open the file.
When this is done in Safari, it works perfectly. You click the button, the file opens in a new tab; you can then close the tab to return to the previous web page.
However now running the application in fullscreen mode - i.e. with the appropriate "meta names" set and from a shortcut on the home screen - when you click the button to load the file, it loads fullscreen with no means to get back to the last page.
Because it is a file, not a webpage, I can't put a "Back" button on, and when you press the iPad button it simply closes the whole thing.
I know this has been asked before and I have read a number of similar questions - the closest of which was this:
https://stackoverflow.com/questions/9168236/web-app-hyperlinks
If at all possible, it would be far preferable (thanks to the control library I am using) that the button click is done with javascript - it is not easy to set the link href.
The upshot is I really I just want to create a new window from within a fullscreen iPad web application, or allow the "back" navigation somehow...
Is this possible?
Thanks!
Create an iframe on your page rather than using an window.open and set that as the target.
That way your pdf would open within your existing window.
Use some client side javascript like jQuery to style it like a dialog window.

Open a popup window on top of a popup window in ASP.NET

I have a scenario where I have a popup window open and that will have links to open up another window that's going to pop open on top of the already open popup window. I've tried all sort of tricks (javascript window.open, target="_blank" etc.) but nothing seem to work. It always was opening the page on the already opened popup window.
Any suggestions? Appreciated your help.
You realize that what you're doing with popups is going to be considered by many users a form of spam right?
But to answer: I believe _resource will open them separately.

Keyboard fails in IE8 after AJAX call

I've run into a strange problem with an HTML form. I've built a dynamic table that adds a new row when you enter data into an existing blank row; because there are some server requirements in adding a row, I make an AJAX call to do this in the onblur event. It took a while to make this work for all browsers, but eventually all was happy with the world ... until IE8. Now, what happens is that, when the call returns from AJAX, the cursor shows in the next textbox (correctly), but the keyboard no longer works. I have to close the modal window (actually an IFRAME), then the keyboard starts to work again. If I put IE8 into compatibility mode, it works fine.
Has anybody seen behavior like this, or have any ideas for a workaround?
Thanks, Jim
I had problems with DIVs placed above an INPUT, that cloacked the cursor... and once the DIV was not above it, the cursor appeared back again.
Just an idea: Maybe your IFRAME captured the focus (and/or the keyboard).

Resources