How to fire a function on page load with javascript the right way? -
this question has answer here:
checked quite lot of info on stackoverflow, in here how call javascript function on page load?
but still problems firing function on load. have one:
code in here: http://jsbin.com/agopuv/2/edit
edited: added html+js codes here js code:
function togglefullscreen() { if ((document.fullscreenelement && document.fullscreenelement !== null) || (!document.mozfullscreen && !document.webkitisfullscreen)) { if (document.documentelement.requestfullscreen) { document.documentelement.requestfullscreen(); } else if (document.documentelement.mozrequestfullscreen) { document.documentelement.mozrequestfullscreen(); } else if (document.documentelement.webkitrequestfullscreen) { document.documentelement.webkitrequestfullscreen(element.allow_keyboard_input); } } else { if (document.cancelfullscreen) { document.cancelfullscreen(); } else if (document.mozcancelfullscreen) { document.mozcancelfullscreen(); } else if (document.webkitcancelfullscreen) { document.webkitcancelfullscreen(); } } } $(document).on('pageinit', function () { settimeout(togglefullscreen,1000); }); and html code:
<input type="button" id="button" value="click toggle" onclick="togglefullscreen()"> and works when pressed on button, did not succeeded in ways fire function on page load.
any advices regarding this? thanks.
requesting full screen outside user action not permitted browser's security policy
read mozilla ua policy
the specification intentionally gives uas great freedom in policy, because no 1 policy can fit users, devices, , user interface designs. however, here policy should acceptable conventional desktop browsers.
- requestfullscreen while window in full-screen state approved.
- otherwise, requestfullscreen outside user action (e.g. non-synthesized input event handler) denied.
- otherwise, requestfullscreen without allow_keyboard_input flag approved.
- otherwise, passive confirmation ui presented , requestfullscreen approved if , when user approves it.
also see similar question
Comments
Post a Comment