Is possible automatic fullscreen with html5? - javascript

I'm based on Using the Fullscreen API in web browsers (http://hacks.mozilla.org/2012/01/using-the-fullscreen-api-in-web-browsers ) for fullscreen , but only works with a click event or with console firebug, not with submit event or mouseover or similar for made automatic. Is possible automatic fullscreen with html5 without click event or similar ?
Edit: I understand the security and accessibility reasons if not possible, but in some environments this can be hopeful.

No, it's not possible - for security reasons accessing full screen requires the user's "permission", and so is tied to browser input events.

No, that is not possible. The requestFullScreen() must be triggered by a direct user action (like a click) for security considerations. It's just the same as with popups.
Read https://wiki.mozilla.org/Security/Reviews/Firefox10/CodeEditor/FullScreenAPI and maybe https://wiki.mozilla.org/Gecko:FullScreenAPI for reference.

Related

how to know what caused visibilitychange

I am using visibilitychange event of the browser. The website is for mobiles. So I test it from my mobile.
document.addEventListener('visibilitychange', (e) => {
console.log("visibility changed", e);
})
This could be caused by many different things.
switching apps back and forth
force-closing app
when the screen turns off
Is there any way to detect what behaviour caused visibilitychange listener to get called? I tried e.target and e.srcElement, but in all cases, they seem to be the same. Any ideas?
Short answer: you can't
As stated in the MDN documentation for the visibilitychange event:
The visibilitychange event is fired at the document when the content of its tab have become visible or have been hidden.
You only have two value possible, visible or hidden. That's all the website can know. You are asking a web browser to have acute knowledge of what the user is doing on his operating system (did he locked his computer? did he switch to a new app? did he kill the web browser?) which is privacy wise, not very useful nor safe.
However if you absolutely need these features and can afford to make the user install your app, you could use something like cordova.

How to prevent firefox window manual resizing?

I use the last firefox release (45.02) on windows 7.
I want to prevent user to resize manually the windows. I have a non responsive GUI, and I want to fix the browser interface.
I can't use the javascript resizeTo(...) function because of MDN docs
You can't reasonably do this. Which is a Good Thing. The user is in control of their browser, not you.
You can control the size of a popup (including whether it can be resized), within reason, so temporarily while you sort out the responsive thing, you could provide users a link to open a window in the size you want:
Open window in XxY for best experience of this site.
then
document.getElementById("open-window").addEventListener("click", function() {
window.open("http://example.com", "", "width=640,height=480,resizable=no");
}, false);
Note that some browsers may still allow resizing, either in the normal way or via a small "grippy" (as the Firefox folks call it).

Trigger System-wide Keyboard Events from a Javascript Chrome App

Is there a way to trigger a system-wide keyboard event (i.e. emulate an actual key being physically pressed) from a Javascript Chrome App?
Currently I've got
target.dispatchEvent(new KeyboardEvent(..));
but this can only be invoked on a target element within the browser.
Ultimately, I want to be able to have a callback
function typeLetter(character){ }
that will type a letter character whether Chrome is the active window or not.
Any suggestions greatly welcomed!
I'm pretty sure this won't be possible between different applications. Even between browser tabs would be an issue I think. If it were possible there would be plenty of security issues that come with it.
Emulating key presses anywhere except the currently-running application (chrome) would open up a can of worms in regards to cross-site scripting attacks and key-logging hacks.

Chrome/FF API for operating with tab's Javascript

I need to control site's javascript via global hotkeys.
I'm trying to control javascript's audio player via Windows Global hotkeys.
But can't understand how to do it.
Language: C#/C++ (Qt). No matter.
Browser: Chrome (maybe other, no matter)
You can use jquery keypress http://api.jquery.com/keypress/
According to the documentation this event will only fire when the element it set upon is focussed.
$(someElement).keypress(function(e) {
console.log(e.which, e.keyCode);
// according to one of the comments e.which should be used in every browser other than IE.
})

How do you prevent firefox from zooming in when pressing ctrl and +?

I am trying to use the ctrl and + combination within firefox for a different action for our web application. How could I prevent firefox from zooming when our web application is listening for this event? I do not want to change a setting within firefox, but would like the code to do this somehow. Any suggestions?
I don't think you can overwrite application shortcuts with website code. Imagine a site overwriting alt + tab, and suddenly you wouldn't be able to tab out of your browser window anymore. It is possible with some plugins, but that depends on the browser you're using.
Instead, use something that isn't a default keyboard shortcut to prevent other users from having the same problems. Everyone expects and counts on ctrl and +- to change their zoom level; overwriting this simply isn't a good idea usability-wise.
You could try Flash. Flash tends to gobble up a lot of shortcut keys, including Ctrl+T (new tab) which drives me mad all the time.
According to this resource http://www.arraystudio.com/as-workshop/disable-ctrl-n-and-other-ctrl-key-combinations-in-javascript.html, you should be able to prevent any control keys.
I have used similar techniques, by catching all events on the body tag, and if they are the F keys, then returning a false to veto.

Categories