I want to hide or disable close icon of pop up window . i have close button in form which will clse the the window using self.close().How i can do it in javac=script. i tried with toolbar=no in window.open, but it doesnt work. Is there any other method to do the same?
You can't do that via Javascript because the close button is a component from the user's operating system. (Javascript can't tell the OS how to behave, it only can work with the browser.)
You cannot disable the close button of a browser window, even if it's a popup. Imagine advertisements that couldn't close. It just has too much potential to be abused.
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 want a popup window to close automatically as soon as the user minimizes the window. My code is as follows:
<a href="#" onclick="Popup=window.open('fb.html','Popup','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=620,height=400,left=230,top=23'); return false;">
any ideas?
There's no event that triggers when the window is minimized. The best you can do is to check the height and width at a set interval. Closing the browser window is trivial Popup.close() should do it.
See a post about programmatically opening and closing pop-ups.
For browser windows or tabs, I believe that you need the user to click a confirmation box (the confirmation is created by the browser as a security feature).
Added Think about your UX (User Experience) -- it is not usual for a user to think about minimizing a window. Perhaps you should provide a "close" button.
Also, investigate the various libraries such as Boostrap modal popups. They already have worked on the UX issues.
I have an application, in that I want to close the entire browser on clicking on the close button from our application. I tried with the window.close() and self.close() functions but they will be closing the browser if the window is opened from window.open().
Please suggest to me how I can close the browser on clicking on the close button?
You can't. window.close() used to do that in a far past, but browsers don't allow that anymore, going from the concept of that a website should be able to stay open as long as it has to. Eg. a website doesn't end. If you log out, you don't close the window, you simply go back to the home page where you let the user log in again. Same with smartphone apps btw :-)
Most modern browsers will only let you close child windows of a parent. You cannot close the parent window through script.
If I open my extension popup then I open another window or tab following the popup does not stay open if I return to it.
Is there a way to force it so the popup stays open?
As a user, you currently cannot force the the popup to stay open. That is a UI decision the UI team made. If you want to want to force a setup, you can have other way to show this by changing the popup icon, open a new tab when it requests, or new popup view for registration.
As a developer, inspect the popup, and it will stay open.
You cannot stop the Chrome pop-up from closing, unless you're in developer mode. You could consider this alternative, though:
Launching a normal pop-up instead:
In your popup.html file, load a Javascript file that runs this:
var popupWindow = window.open(
chrome.extension.getURL("normal_popup.html"),
"exampleName",
"width=400,height=400"
);
window.close(); // close the Chrome extension pop-up
This will open the file normal_popup.html in your extension in a normal pop-up window, which won't close when it loses focus. Because the name parameter is the same, the pop-up window will get reused if the user launches popup.html again.
In an answer to a FAQ here: https://developer.chrome.com/docs/extensions/mv3/faq/#faq-persist-popups
Popups automatically close when the user focuses on some portion of the browser outside of the popup. There is no way to keep the popup open after the user has clicked away.
As others have said, this is a deliberate limitation of popup UI.
Instead, you could inject some HTML into the page which loads the content you want in your popup into an element which hovers over the existing page. You will have to implement the close functionality yourself, but it will persist.
Have a look at e.g. how keyframes.app has done it: https://github.com/mitchas/Keyframes.app/blob/master/Keyframes.app%20(Extension)/src/inject/ui.js
If you enable panels at "chrome://flags/#enable-panels" you can use something like:
chrome.windows.create({
url:"popup.html",
type:"panel",
width:300,
height:200
});
to open a panel window instead which will stay on top all the time as long as you don't move it from the bottom of the screen.
Best way to workaround this is to :
Right-Click inside the popup
Click: Inspect
Or just press CTRL+Shift+I
A new window will open with the Developer Tools... just keep that window open and the popup will never close.
This answer to How do I prevent Chrome developer tools from closing when the current browser window closes? what very helpful in my case:
Not a perfect solution, but you can add breakpoints on the events Window.close and unload by turning on the checkboxes at:
Developer tools -> "Sources" tab -> Event Listener Breakpoints -> Window -> close
And
Event Listener Breakpoints -> Load -> unload
Try to mark both and see which one works best for you