How to make options for popup window..eg size - javascript

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.

Related

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

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.

Open new tab in browser window (opened with window.open)

I have a new window opened via window.open method and in that window in content I have a link with "target=_blank".
When clicked the link opens new tab in parent window instead of the one that content was in. I also noticed that for that window (created with window.open) the Ctrl+T shortcut (to open blank tab, Firefox) does not work.
I checked window.open specs and I didn't find any option that would allow this behavior.
var a = window.open("http://www.google.pl",
"Test",
"width=640,height=480,scrollbars=yes,toolbar=yes,menubar=no,location=no,resizable=yes");
a.focus();
Setting toolbar=yes makes it work in Firefox. Any idea how to make it work in chrome?
Could you show some code?
else; try with javascript:
function OpenNew(){
window.open("http://www.google.se", "_blank");
}
Rgds

window.opener issue with window.open() when replacing a window

I have a web application where page #1 opens a popup window using
window.open(myUrl, "fixedApplicationTargetId", "");
Then page #2 overwrites the same popup window with a call to window.open using the same target value
window.open(anotherUrl, "fixedApplicationTargetId", "");
At this point the content of the popup originally created by page #1 shows the new content created by page #2. So far so good with any browser.
Then the popup itself detects who last opened the popup and updated the content using window.opener. Prior to calling window.open both page #1 and page #2 create a global variable globalPageId and assign a unique number each. The popup checks the value of window.opener.globalPageId and detects which window last updated the popup content.
This is where things fall apart: the above works fine with chrome and firefox that update window.opener in the popup each time the content is updated with window.open. Instead, IE and opera always point the popup window.opener to the first window that used window.open.
Any suggestion, in a context where multiple pages call window.open on the same target, how to detect from the popup itself which window last opened the window?
window.opener is supposed to be read-write (except in Internet Explorer 3), so you could set it to the appropriate window yourself. Some browsers, however, restrict this operation and only allow setting opener to null to prevent security issues.
An alternate solution would be to use a custom property instead of opener. You could set it by hand:
window.open(myUrl, "fixedApplicationTargetId", "").realOpener = window;
Then use window.realOpener.globalPageId instead of window.opener.globalPageId in the rest of your code.

Way to open popup in a new window

Is there any way to force IE8 to open new window only in a pop-up? I don't want to change the browser settings. I want to open it and throw Javascript window.open(). Firefox is opening it in a new window but IE8 is opening the same in a new tab. Please suggest.
hold a SHIFT button while you click on an Internet hyperlink on your browser screen. This will force the link to open in a new window
You cannot control whether a browser opens a window in a new tab or new window.
Although, one work around is to set height and width dimension in the call to window.open() alongwith disabling the addressbar and statusbar.
window.open ("http://www.example.com", "mywindow","status=0,toolbar=0,height=600,width=900");
It worked for my case, I'm not sure if this satisfies your 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

Categories