I'm working on an app that uses this to open the homepage of the application after they have successfully entered the login details:
window.open("app_homepage_url","myApp","toolbar=no,status=yes,scrollbars=no,location=no,menubar=no,directories=no");
This normally works as expected and hides the toolbar but one user has reported that they still have the toolbar showing. They are using Internet Explorer.
My first thought was maybe there's already a window open with the name 'myApp' and the toolbar shown so the homepage is getting loaded into that window instead of a new one but I tried doing that and the application does not let you log in due to the way the login is handled with sessions so I don't think it can be that.
The comment on this answer seems to suggest there is a way to force the browser to always show the toolbar so I wonder if it is to do with this. Does anyone know how you actually do this?
Any other ideas?
This might be a browser configuration issue.
Have a test on the following configuration settings on IE7 and IE8:
Goto Tools->Internet Options->Security Tab
Select an appropriate security zone settings
Click on Custom level.. button
On the settings tab, look for Miscellaneous Node
Then have a test on the following settings
Allow script-initiated windows without size or position constraint
All websites to open windows without address or status bar.
Closing the browser might helpful when changing configuration settings.
Related
I have a very, very weird issue that only seems to be an issue in Chrome.
When a user comes on the website, the user cannot focus any element (via mouse click, if they focus it via tabbing, the elements don't get the 'focused' state either) and that's only an issue in Chrome. That is, until the user resizes the window, minimizes the window, opens a new tab, opens developer tools, etc. Reloading the page does nothing. However, as soon as focus is "enabled", the user can navigate/refresh with purging cache, etc., close the browser and open it again, and everything works normally - the elements get the 'focused' state normally.
This behaviour can only be reproduced in Chrome and not on localhost.
The difference between localhost and beta environment is:
beta env requires authentication (basic http auth)
files in development env are concated in a single JS and single CSS file and both are minimized
beta env includes hotjar, while there's no hotjar on localhost
There are no custom event listeners that would listen for the 'resize' event. There are no errors in console and all javascript that doesn't depend on focused element state gets executed correctly. Hover events and all CSS styling that depends on hovered state all work correctly.
The main issue is, that a form which has to be filled out and includes a datepicker, cannot be filled out and thus the users can't really interact with the page. Datepicker doesn't open and, as the input elements don't get the focused state, they don't visually change (CSS :focused selector isn't working either) and thus give the impression to the user that they cannot type in the normal text inputs (which works, after clicking on the input, it is possible to type in the input).
I have tried removing hotjar and the problem persisted. The only thing that made the problem go away was removing the basic auth, however, that is not an option in this stage (it's a closed beta test, so we need to limit the access only to the users with password).
I also find it extremely odd that basic auth would interfere with the focused state of elements, especially as the error persists after you refresh and only goes away as soon as you interact with browser itself (minimize, open new tab, do anything that resizes your browser window or document), after that it works correctly and there are no errors whatsoever.
The problem only started to appear recently, but I do not believe it's an issue with the app itself, as I tried rolling back to a couple months old build and the problem persists. All of that makes me believe it's a bug in Chrome, but what can be done to fix it?
EDIT: I also tried to add autofocus property to an input element and, in beta environment, it doesn't get focused.
So it seems it indeed is a Chrome bug that's present both on mobile (Android and iOS) Chrome browsers, as well as desktop Chrome browser (tested both on a Windows and a Mac). I submitted an official bug report. In the bug report, a fellow user made a website that's accessible only through basic auth and only has 2 basic inputs, the input should get a red border on focus. As expected, after opening the webpage in Chrome (for ease of use - incognito mode), the input doesn't get focus and the border doesn't change.
For those who are also affected by this bug in Chrome, you can track the bug progress here: https://bugs.chromium.org/p/chromium/issues/detail?id=740652
Meanwhile, here's a hacky solution for those interested:
$(document).on("ready", function() {
var $inputs = $("input");
$inputs.off("click.trick");
if (!sessionStorage.fixedChromeFocus) {
sessionStorage.fixedChromeFocus = "true";
$inputs.on("click.trick", function() {
var win = window.open("/", "_blank");
setTimeout(function() {win.close()}, 1);
$inputs.off("click.trick");
});
}
});
The goal is to, somehow, interact with the browser outside of the current page, to make it somehow lose focus. You cannot use JS to minimize browser, cannot resize it, cannot open dev tools. What you can do, though, is open a new window. Of course, if you open a new window immediately, a pop-up blocker (as most people have it) will block it and the window itself (or rather your current tab) won't lose focus. Opening a new window can only be done as a reaction to a user event (without triggering potential pop-up blocker).
I also use some browser detection so the code will only be executed for Chrome and, using server-side conditioning, only for builds that include basic auth.
What the code does, quite self evidently, is that as soon as a user clicks on an input, it opens a new tab and quickly closes it, 1ms later. To prevent this from happening all the time, on every page load, sessionStorage, which gets cleared automatically after tabs from that domain are closed, is used (and we've already established that once focus starts working correctly, it will work as long as you keep your browser open).
The effect of this code is that the user will see a quick white flash the first time he clicks on the input, but everything will work correctly
I am working in vb.net 2005. I am in a position to start a new browser with process.start().
Now I have to open that browser in a specific size(say height:300 width:500)
Process.Start("firefox.exe", "abc.html")
and I have written this following code on load of abc.html
var myRef = window.open('abc.html','','left=20,top=20,width=300,height=500');
but it does not resize.
If I add 1 button on this page and click on it (by writing same code on its click event), a new window with expected size opens.
Am I going wrong somewhere?
Thanx.
Firefox doesn't let pages resize the window by default. Also note, if you already have Firefox running then browser preferences will dictate whether you get a new window or a tab. You can force a separate instance of Firefox by using the -no-remote command line flag, but then you won't be able to use the default profile (only one Firefox instance per profile).
My questions for you are:
Why are you launching Firefox from another executable at all instead of just having users click on a link and have it open in their default browser?
If you do need to launch Firefox from an executable, why spend all this effort overriding the user's preferences and settings?
If you' re launching from an executable and are keen to annoy your users whatever the cost, why not just find and resize the Firefox window using the normal Windows APIs?
I made a uploader that allows drag and drop but because people usually browse with their browsers taking up most of the screen I would like to make the browser smaller when a user clicks a button so its easier for him/her to drag the files in...
Is there a way to resize a browser window thats already open...
or at least to minimize the browser in js??
I know there is window.resizeTo(w,h);
but it doesnt work for me
Update
can users choose to unblock this functionality for a specific website??
and is there a way for me to check if a user allows or blocks that option?
Will i still be able to use window.resizeTo(w,h); is i make a new window pop up ??
Because if i am i will try defaulting to that.
If its possible to allow resizeTo(w,h); for a specific website (i mean by user settings or editing some files on the computer not by js even if it only works for some browsers ) how do you do that??
(even if its really difficult i would like to know)
Similar Question (with an answer how to do it in chrome):
set_browser_window_size
Another One (this one explains how you can check about:config values with js)
check about:config with js
It be nice to see a list of browsers that support the resizeTo function with the version number.
Almost all new browsers disable this event by default for the reason of annoying users and malicious actions.
At some browsers users allowed to enable this action manually, but ~95% of users will have default settings. To enable resizing at Firefox you can go to about:config and set dom.disable_window_move_resize;true attribute to false
You can try to resize user window at any time with window.resizeTo(w,h); method and then check current user screen height. ie with jQuery method var curH =$(window).innerHeight(); and compere h with curH to be sure that its resized.
The better way to solve your problem is to allow users to drag files from the folder to the specific area of the screen or open dialog on action with multiple files selection.
Addons
Maybe the best choose will be to organize uploading at your website with own addon for most of popular browsers. You can write your own for Chrome, Opera and Firefox.
Advantages:
Users do not need to read tons of rules about how to enable something. Only few click to install addon.
Well-controlled and stability work.
You can provide access to files upload functionality without visiting your site at all.
I'd need the following functionality for Google Chrome.
I didn't find a command line parameter that could help me here.
check if a URL is open in one of the Google Chrome tabs
if so, activate this tab
if not, open the URL in a new tab
Any ideas how to solve this?
I think Chrome extensions docs - Tabs will help you!
Just to make it clear you can't NOT access anything beyond your Domain in JavaScript because of Same origin policy.
Using Javascript, triggering an alert can have the desired effect. Run this code in your console in one tab and switch to another tab in the same browser.
setTimeout(function(){
alert("Switched tabs");
},
5000);
The alert appearing after the timeout will trigger tab switch. Or you can do something similar! This should however be used if absolutely necessary to move user from current tab, like Google Calendar does.
Update 2019
With new versions of Chrome, this no longer works. As pointed out in the comment below, Chrome now shows a small icon in the tab to show a window/alert has been triggered
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