How to open popup in JavaScript? (NOT window.open) - javascript

This is kind of a dumb question, but what is the command to open a popup window in JS? I know that window.open works, but on chrome, it shows the tabs, which I have seen in popups not existing. It should just show the address at the top. Hopefully I expressed this question correctly.

Default behavior is to open in a new tab. However, using the third parameter windowFeatures in the window.open(...); function will allow you to set parameters to force the request to open in a new popup with the minimal UI elements that you're requesting. For example:
window.open("{url}", "_blank", "popup=yes");
Reference Documentation: window.open()

Specifying the popup option in the windowsFeatures (third) parameter should produce the result you want.
window.open('', '', 'popup=true')
Learn more about window.open from MDN, here.
Hope this helps.

Related

HTML in a window

I want to make a window with HTML that works similar to ones opened by windows. I know the method with actual browsers, but it isn't good enough as I have link and navigation buttons.
This would make my job easier in making softwares with lots of animations
The best you can get is calling Window.open with third argument set as: 'menubar=no,location=no,resizable=no,scrollbars=no,status=no'.
This will open a new browser window with only the address bar shown.
There is no way to open a native window out of the browser's scope from JavaScript code other than this. It is a security limitation.
However, the other alternatives include are Window.alert or a Window.prompt.
If you want to open a popup box you can use alert("This is a dialog box!");, confirm("Is it ok or not?"); or prompt("Enter a value and confirm it or not");.
https://www.w3schools.com/js/js_popup.asp
If you want to open a native window, that is not possible as it has already been said.

Functionality of window.open() in google chrome

I am not a very experienced javascript programmer by any means, but I am trying to prototype something for design purposes and I need some help. Here are some questions I have about window.open() in chrome
How do I get the page to open in a new window. Not just another chrome tab.
Is it possible for me click a link in one window and have it open in some other window already open on my browser.
If I can open it in another window it is possible to specify which tab. Whether it be a tab that's already open or opening a new tab.
Thanks
I would like to quote other answers from helpful posts that will go more in depth to what you need to know, all the answers here are in javascript:
Open a URL in a new tab
also
Open URL in New Window with Javascript
open url in new tab or reuse existing one whenever possible
also
I want to open a new tab instead of a popup window
You cannot open new windows or new tabs that your Javascript does not already know about because its outside its scope.
I hope this helps, please feel free to comment if you need anything further!

window.open() still returns null

I am using IE8 on Windows 7. Referred to several threads and understand that in IE8 when I am using window.open to popup a new window, the JavaScript window.open is returning null value.
If I run IE as administrator or disable the protected mode, I see the window.open returns the expected object.
I am looking out for a solution apart from the options mentioned above. For such a small feature (opening a popup) I cannot ask customer to run IE as administrator or disable the protected mode.
If there is any work around, please let me know. It will be a great help.
Primarily, I want to make sure that only one window is opened when user clicks multiple times on the link and give the focus to the window which is already open. To achieve this I need to get the object from window.open so that I can check if the window is already open and give the focus to the already opened window. Otherwise open a new window.
For IE10, window.open returns a NULL reference object if Enable Protected Mode is checked under Internet Options->Security->Security Level for this zone and the ZONE is different i.e. in my case local file opening a popup from Intranet.
window.open returns a reference object even if Enable Protected Mode is checked when yoursite.com opens someothersite.com in popup window i.e. Internet->Internet
You can use window.showModalDialog as a alternative or replacement for window.open method.
It is more secure then window.open. It will not allow user clicking the Parent page.
Example Usage:
var myFeatures = "dialogWidth:1060px;dialogHeight:550px;resizable:yes";
window.showModalDialog(url,window,myFeatures);
//Here window is an object, no need to assign or declare.
If you want more detail explanation see Here.
//Fifth Question.

How can I modify this bookmarklet to work on a tab instead of a new window?

When you put this in your browser it opens a simple notepad to type in.
I don't know enough about javascript to alter it but I would like to make it so it DOESN'T open in a new window but rather in the current window or another tab.
Is this even possible?
javascript:pwin=window.open('','_blank','menubar=yes,scrollbars=yes,location=no,height=450,width=350');pwin.document.body.contentEditable='true';pwin.document.designMode='on';void(0);if(window.focus){pwin.focus()};
Technically, window.open does not always open in a new window. You can use _self instead of _blank, and it will open in the same window. Or use _parent and it will open in the current frame's parent.
Window.open always opens this in a new window.
Instead I think you can try window.location. Not tried tough.
Ok did a little digging and there is nothing you can do that will guarantee that it will open in a new tab. However if you remove the width and height parameters some browsers will open in a new tab if user preferences haven't overridden this behavior. See this post (2nd answer in list) Stackoverflow post
If you aren't looking to open a window, then don't window.open()
Setting window.location should do the trick, as pointed out by Sachin

How to make options for popup window..eg size

I have the following function to make a popup window.
function makewindows(html){
child1 = window.open ("about:blank");
child1.document.write(html);
child1.document.close();
}
It works fine, but it opens a new tab in firefox. I would like to know how to make it an actual popup, with a smaller size and such, separate from the actual window.
window.open("example.html", "windowName",
"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no");
See the MSDN window.open documentation or the Mozilla window.open documentation for more details.

Categories