detect browser window resize without event - javascript

I would like to know if, in Javascript in general (and in Angular in particular), it is possible to check if the browser window has been previously resized by the user, e.g. if the user has landed on my page on an already resized browser.
Thanks in advance,

Related

Window.open alternative

I want to open the browser in background using window.open
But that new browser should not be visible
Or please suggest any alternative of window.open
Any help would be appericiate.
But that new browser should not be visible
You can't do that with browser-based JavaScript (or HTML, for that matter).
You can have a zero-height iframe in the window your code is already running in. I've done that when I needed a target for a form that results in a downloadable file: I target the zero-height iframe and when the response comes back, the user is prompted to save it somewhere. (I do that instead of using a new blank window to avoid having a window pop-up that the user isn't going to use for anything, esp. since the window didn't go away in IE at the time I did this.)
If by "not be visible" you just mean it should be hidden behind the existing window (a so-called "pop-under"): Browsers are very good at preventing pop-unders these days, since they've been used for malicious purposes so often.

How to detect if current window is behind another window, using Javascript

Is it possible to detect whether the web browser window is currently covered by another window?
document.hidden and document.visibilityState only changes state on switching tabs or when the entire window is minimized.
document.hasFocus() returns false if the window is visible but not in focus (e.g. the focus is on the taskbar)
Nope, that's not possible.
There's no way in JavaScript to know how visible the window is.
Browser windows overlapping one another, the position of the browser windows, and which one of them is on top - these functionalities are handled by the operating system.
No matter what code you write for your webpage, you cannot tell if your browser window is overlapped by another.
So yeah, the answer is NO.

How to check the browser page is always on the top using javascript

I have write a test site, when user begin test, i will open a new window, and i don't want user can change the browser window, how could i check the user is always on my window, i can only thought to check whether the user is pressing the alt+tab or the mouser is leave the window use javascript. So, Are there any other better solution?Thanks!
I don't think there are any other solutions.
The browsers wouldn't let you do this.
But I can't see how it would work with the solutions you have:
- You can't set the position of the cursor, so you can't stop the mouse in leaving the window,
- You can't stop the system in using the Alt+tab, you can only controle the browser window.
But if you're getting it work, please write your solution in this threat, thanks

Change Window State to Fullscreen

How can I change the web browser window state to Fullscreen in javascript(Like when user press F11)? I know how can I specify Window State of new Window that has been opened by Window.Open Method but I want to change the sate of current Window.
You can't and you shouldn't do this.
You shouldn't do this, because it is a annoying user experience. So let the user decide and maybe ask him to press the button for fullscreen mode, but never force him.
You can't because the browser vendors disabled this feature for the reasons of my last point.
Minimal workarround would be to set the window size of the new window to something close to the screen resolution, but this could be tricky if the user has a dual screen.
You can't.
Just ask for the user to press to press F11 and then detect if the user pressed it by checking the key code 122 (eg: keyup event) and comparing the size of the window with the size of the screen (screen.width/height and window.innerWidth/Height).
It's not perfect, specially for users with multiple screens.
You can open a window without toolbars with JS:
window.open("http://www.stackoverflow.com","mywindow","menubar=0,resizable=1,toolbar=0,status=0,width=5000,height=5000");
It will probably be blocked by popup blockers, but that is the most you can do.
So far I know, it is only possible with security privileges, like in an intranet.
For example:
The InternetExplorer.Application ActiveX objects have a "fullScreen" method.
In Firefox 3+, if you have Chrome-privileges you can use "window.fullScreen = true;"
but without those privileges this property is read-only ( https://developer.mozilla.org/en/DOM:window.fullScreen ).
Easy.
<strong>Please view in fullscreen (F11 on most browsers).</strong>
Here's why
No, there's no cheat to remove control of a browser from the user.

Javascript within page to open fullscreen

I have a htm page that I need to update so that when it is opening it will open at fullscreen. What is the code that I need to place within this page to do so?
Most browsers don't support opening windows in fullscreen. I suggest you only use the document size you are given.
This is not possible.
Don't do this. Firefox doesn't implement this because people just don't like it. You should assume users have their browser the size they want for a reason.
You can't (and shouldn't) force fullscreen, but you can (though probably shouldn't) use Javascript to maximize the window size:
window.outerWidth = screen.availWidth;
window.outerHeight = screen.availHeight;
But as previous people have stated, resizing a user's window is likely going to annoy him.
If fullscreen is really important for your application, you might consider giving the user instructions to switch to this mode manually. You COULD use Javascript to customize these instructions to a users' browser/OS.

Categories

Resources