Javascript “window.open” code won’t work in Internet Explorer 7 or 8

It’s the space in the second parameter that’s causing it. If you use “UploadPhoto” instead of “Upload Photo”, it works: $(‘#change_photo_link’).click(function(){ $id = $(‘#id’).attr(‘value’); window.open(“photo.upload.php?id=” + $id,”UploadPhoto”, “menubar=no,width=430,height=100,toolbar=no”); }); I can’t seem to find any official reasons as to why having a space in the windowName parameter of window.open() causes an error, but it’s likely … Read more

window.open returns null and fails in inline script but works from console

It is blocked by the browser. window.open is only not being blocked, when it is invoked by user action, for example in a click event, emitted by a native browser event. Also javaScript emitted events are being blocked, just like delayed setTimeout callbacks. <a id=”link” href=”http://stackoverflow.com”>StackOverflow</a> <script type=”text/javascript”> // Example (with jQuery for simplicity) $(“a#link”).click(function … Read more

Javascript,calling child window function from opener doesn’t work

The window creation is not a blocking operation; the script continues to execute while that window is opening and loading the HTML & javascript and parsing it. If you were to add a link on your original page like this: <a href=”#” onclick=”addWindow.getMaskElements();”>Test</a> You’d see it works. (I tried it just to be sure.) **EDIT … Read more

How to get the references of all already opened child windows

If you don’t want to change your current code, you can simply override window.open() function: var openedWindows = []; window._open = window.open; // saving original function window.open = function(url,name,params){ openedWindows.push(window._open(url,name,params)); // you can store names also… } Run this code before calling window.open(). All the references to the opened windows will be stored in openedWindows … Read more

Window.Open POST

You cannot trigger a javascript popup and then force a post request. Three options: Trigger a POST form with target=”_blank” using javascript (but this doesn’t allow you to disable interface elements such as the menu bar). Open a popup locally, but don’t specify a url. Use the result of window.open to alter the document to … Read more

How to set a file name using window.open

You can achieve this using the download attribute for <a> elements. For example: <a href=”https://stackoverflow.com/questions/7034754/1251354216241621.txt” download=”your-foo.txt”>Download Your Foo</a> This attribute indicates that the file should be downloaded (instead of displayed, if applicable) and specifies which filename should be used for the downloaded file. Instead of using window.open() you could generate an invisible link with the … Read more

window.open() on a multi-monitor/dual-monitor system – where does window pop up?

Result of “window.open dual-screen” search revealed this fancy nugget: Dual Monitors and Window.open “When the user clicks on a link that opens a new window using window.open. Make the window appear on the same monitor as its’ parent.” // Find Left Boundry of the Screen/Monitor function FindLeftScreenBoundry() { // Check if the window is off … Read more

Why is window.showModalDialog deprecated? What to use instead?

Why is window.showModalDialog deprecated? From http://tjvantoll.com/2012/05/02/showmodaldialog-what-it-is-and-why-you-should-never-use-it/, In general the idea of putting a native dialog implementation into the browser was a really good idea, but window.showModalDialog was a bad implementation that is riddled with issues and poor browser support. (…) Note that (…) [a modal dialog using showModalDialog] is a full HTML document, not a … Read more