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.
Related
I have MyPage.aspx html page (generated using ASP.Net). When user tries to navigate away from this page, I need to close the window – user should not be able to go back or navigate to another page.
When I used window.close() inside window.onbeforeunload event, it asks for a confirmation to the user. “The webpage you are viewing is trying to close the window. Do you want to close the window?” On clicking “No” the user can escape the close attempt. Is there any way to forcefully close the window without giving an option to the user?
Reference:
How can I close a browser window without receiving the "Do you want to close this window" prompt?
Html javascript to open new window and close current window
"Unknown Exception" when cancelling page unload with "location.href"
Display confirmation popup with JavaScript upon clicking on a link
You can "trick" the browser like this:
window.onbeforeunload = function() {
window.open('', '_self', '');
window.close();
}
It seems to work in chrome/safari/ie/ff: http://jsbin.com/olijig/1
Firefox seems stubborn, but there might be another way to do the same in FF.
I should probably say that this technique is in no way standard and I don’t recommend it at all, and this code might break in many browsers besides firefox.
UPDATE
It actually works in Firefox too (latest version), but not older versions (I tried 3.6.1). You need to do some more testing to confirm the browser compatibility.
No, you can't. The user must be always capable of controlling whatever happens in his browser.
I'm not positive about this, but I believe if you have a window open another window, the parent window can close that child window. Would it be practical to have a landing page that opens your app in a separate window that could then close the window through javascript? Someone can probably elaborate more, as I haven't done this myself.
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).
I am thinking about opening the help page of my application in a popup1. My problem is that I don't want to open multiple popups if the user clicks the help button more then once.
Is it possible, in a cross-browser way, to reuse an old popup window instead of opening a new one?. I'm hoping I can bring it back to the foreground2 or something like that.
In the worst case I think I can go back to a div-based Javascript dialog but I'd rather avoid that if possible.
1 Most normal desktop apps use popups for the help dialogs so I don't think there is anything wrong with this choice.
Also, I think in my case a normal link to a help page would be suboptimal from a practical perspective (I don't want people navigating around too much in my single-page app) and from a technical one (the help contents are created via Javascript and using popups + document.write is more flexible for me)
2 Some comparisons with Windows desktop apps: Windows Explorer and IE refocus the old help window if you try to open it again. Office apps have the help window always on top. Firefow and Chrome just open a new browser tab (and open multiple ones if you try again)
I usually just use focus()
function help_open(id) {
newwindow = window.open('help.php?id=' + id, 'popup_return', 'menubar=no,history=no,resizable=yes,scrollbars=yes,toolbar=no,width=800,height=600');
if (window.focus) {newwindow.focus()}
}
<a href="something" target="yourname">
while yourname same the same window will be focused
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.
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