How to Open Multiple stand alone browser windows using JavaScript? - javascript

I have html page with 2 links like
Visit W3Schools
Visit W4Schools
I want when user clicks on one of them to open new fully powerful browser window with that link. I want user to be capable of opening more than one window from my page. I need it to work via pure JS or using jQuery. It needs to work in Safari 3 and Internet explorer 6,7,8.
How to create such thing?

You can set the target attribute as _blank.
Visit W3Schools
This will open the new page in a new window or a tab depending upon the browser setting.

Target="_blank" is invalid
in js you can do this with window.open()
window.open(URL,WidowName,Options)
You have this options
1. width=300
Use this to define the width of the new window.
height=200
Use this to define the height of the new window.
resizable=yes or no
Use this to control whether or not you want the user to be able to resize the window.
scrollbars=yes or no
This lets you decide whether or not to have scrollbars on the window.
toolbar=yes or no
Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.).
location=yes or no
Whether or not you wish to show the location box with the current url (The place to type http://address).
directories=yes or no
Whether or not the window should show the extra buttons. (what's cool, personal buttons, etc...).
status=yes or no
Whether or not to show the window status bar at the bottom of the window.
menubar=yes or no
Whether or not to show the menus at the top of the window (File, Edit, etc...).
copyhistory=yes or no
Whether or not to copy the old browser window's history list to the new window.
http://www.pageresource.com/jscript/jwinopen.htm
a valid jQuery and html solution is
$("document").ready(function(){
$(".blankTarget").live("click",function(){
window.open($(this).attr("href"));
return false;
});
});

You can use Some text which will prompt the browser to open a new window but this can be overriden by specific user settings/configurations in some browsers.
Beyond that, you cannot force the operating system to launch a new instance of a browser from Javascript - that would be a massive security risk!

target="_blank" is the best way to solve this as it doesn't involve javascript. Please bear in mind that this attribute is frowned upon and you should really let the user decide if they want to open the linked page in a new window or the window they are currently using. W3C agree with this and as such your code will not validate using their validation tool.
Alternatively this post describes how to implement a jQuery solution.

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.

How to disable browser minimize, maximize and close button on page load using JavaScript or jQuery

On page load minimize , maximize and close button disable in any browser.
I don't think you can alter these settings on an existing window but you can affect these settings on a window that your code creates using the window.open() method.
See Window.open() on MDN. There are a ton of options you can set and mileage may vary per browser. i.e. it may not work in all cases. Also take note of the usability issues of window.open() in the same article.
example:
window.open('http://www.google.com', 'WindowName', 'minimizable=no,scrollbars=no,resizable=no,titlebar=no,location=no')
It did not work exactly as expected in my tests with Chrome. e.g. turning off the location bar resulted in a read only location bar rather than removing it altogether. Other options were seemingly ignored. I think many A-Grade browsers are dropping support for this sort of thing due to potential for abuse from malicious sites.
By default, max button of a window is enabled, but if you open as pop-up and pass some value as the window property in that case the max button might be disabled, please see below way to do this job:
Set window resizable property as either no or 0.
Format:
window.open("pageurl","PopupWindow","resizable=no"); //OR: resizable=0
Examples:
window.open("http://www.google.com","PopupWindow","resizable=0");
window.open("http://domainname.com/somepage.ext","PopupWindow","resizable=0");
window.open("http://domainname.com/somepage.ext","PopupWindow","resizable=no");
releated posts
http://forums.asp.net/t/1474854.aspx
How To Disable Button Close On Browser For Web Application?

Is it possible to remove all chrome from a browser window (not full screen)

Is it possible to remove all "chrome" from a browser window, without going full-screen (with or without CSS/js) Ala Quicktime modal?
So all you see is the content and the drop shadows no toolbars, not even the close/minimise/minimise toolbar.
No, it isn't.
You can open a new window with some chrome removed using the strWindowFeatures features of open, but you've never been able to remove the title bar and more features set to Always On by browsers as an anti-phishing measure.
You could get something similar to what you are asking for by just using an iframe in an existing page. Obviously, it won't be free floating.

How to disable maximize,mimimize and close button for a new window open

I am using window.open() method to open a page as a pop-up window for a link button click event.
But the poup-up window is having minimize,maximize,close(x) button.
I dont want those buttons. How can remove these buttons?
This is the method i am using,
window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,titlebar=no,scrollbars=1,resizable=0,width=450,height=310,left=500,top=350");
Tell me how can do this.
Regards,
Chirag Jain.
You can't.
If you want a popup style window without full window decorations you'd have to create a new overlay <div> on top of the existing content and fill that with content, perhaps using an <iframe>.
You can't do it from javascript alone. Think about it, if you could, then people could put it into code on web-pages and cause other people's computers to open windows they couldn't easily close.
Instead you'll have to look for an answer specific to whichever browser you're using to host this application, and change it on the computers of your users appropriately. Even then though I don't think you'll be in luck (with Firefox for example, I can see how to get rid of them on all browser windows, but not on just one).

Maximizing the current window in javascript

Is there a way I can maximize a currently minimized window from Javascript? Here's my situation:
I have a series of links that all target the same external window (e.g. "MyNewWindow"). When I click a link, a new window pops up. If I click another link, the page pops up in the same window as expected. If I minimize the "MyNewWindow" popup, I'd like to be able to click another link and have that window maximize.
My approach was to put something on the onLoad part of the body so that when the page is refreshed it will automatically "maximize" if it is minimized. Note: Using window.MoveTo() and window.resizeTo() doesnt seem to do the trick (the window stays minimized).
Thanks!
For all of you know-it-alls, there are perfectly good reasons to want to know how to do this. Here's the reason I needed this:
I'm deploying SCORM modules to a variety of Learning Management Systems (LMSs)
One LMS that a client is using launches the module in a small (600x400) window, with the user controls to maximize or resize said window DISABLED
The client doesn't know how to change this launch behavior
My only option is to try to maximize via javascript, because the idiots who made the LMS took away the user's ability to manage their own windows.
window.moveTo(0, 0);
window.resizeTo(screen.availWidth, screen.availHeight);
This may not work in IE depending on the security zone your page is falling under, and it may not work in Chrome at all. But for a corporate environment in an intranet, it has a good chance of working.
Don't do this, you are not allowed to do this by most modern browsers for a reason.
In a tabbed environment you're not messing with only the window you may have created, but all of my tabs, that's unacceptable. It's the user's computer, user's browser, it's the user who chose to go to your site...let them size the window the way they want it, doing anything else breaks their experience...and their trust in your site.
The behavior you're looking to emulate is what your run-of-the-mill malware does...re-think your approach, please. For example focusing that window is appropriate for what you want, let the default behavior of the browser take over from there, like this:
var thatWindow = window.open(url, "linkWindow");
thatWindow.focus();
try to use window.open(url,fullscreen=yes);
if you out fullscreen=yes than while clinking on link automatically

Categories