Home › Forums › Programming › FullScreen javascript make fullscreen responsive without clicking
- This topic has 15 replies, 2 voices, and was last updated 1 month ago by
c4cc.
-
AuthorPosts
-
2025-07-15 at 4:25 am #83068
c4cc
CustomerI’m trying to get fullscreen immediately responsive to users’ input when button is clicked on – (like Verge3d viewport fullscreen’s – that scene is immediately reactive to player’s input when the fullscreen button is clicked)
How do I get this code to work?
2025-07-17 at 6:40 am #83196c4cc
Customer2025-07-17 at 7:31 am #83202c4cc
Customer2025-07-22 at 9:21 am #83254c4cc
Customerfailed to apply this, where did I go wrong:
source:
https://stackoverflow.com/questions/2890921/simulating-click-with-javascript-on-document2025-07-24 at 7:33 am #83292c4cc
Customeri tried to apply
v3d.play();
, yet this didn’t cause fullscreen to be responsive immediately when fullscreen button is clicked on? Still have to click fullscreen again to get Verge3d to respond.2025-07-24 at 7:38 am #83296c4cc
CustomerEven this does not work. Still have to click fullscreen again to get Verge3d to respond. How do I get fullscreen to be playable immediately after clicking the HTML element for fullscreen?
window.onload = function() { v3d.play(); // Ensures the scene starts playing if there are animations or interactions. };
-
This reply was modified 1 month, 1 week ago by
c4cc.
2025-07-25 at 3:39 am #83312c4cc
CustomerTried this, still does not work?
HTML
<div id="fullscreen" title="Fullscreen" onclick="fullscreen();"><img src="https://i.postimg.cc/0ykypt59/gameplayerfullscreen.png" style="width:22px;height:20px;"></div>
Javascript
let fse = document.getElementById("fullscreen"); fse.onclick = fullscreen; fse.click() document.onclick = fullscreen;
2025-07-25 at 6:57 pm #83322Alexander Kovelenov
StaffHi,
Please explain more what you’re trying to achieve. In any case it appears what the required functionality can be implemented with puzzles, not JavaScript. If you’re trying to run some logic then fullscreen is enabled, just use the init fullscreen on some custom element and disable the standard fullscreen buttons in configure application.-
This reply was modified 1 month ago by
Alexander Kovelenov.
2025-07-25 at 7:30 pm #83329c4cc
CustomerI’m trying to make fullscreen immediately reactive to user input after the website icon/button clicks the fullscreen feature
think of it as the Verge3d internal fullscreen feature, where users can immediately interact with scene after fullscreen is activated, but with html, HTML.DOM and javascript instead.
Or like browser games being immediately playable after fullscreen is activated
-
This reply was modified 1 month ago by
c4cc.
2025-07-26 at 7:10 am #83331Alexander Kovelenov
StaffThen you should delay the game start (e.g. playing animations/music/showing characters) etc till the user clicks on the fullscreen button.
If you’re going to register custom fullscreen handler and don’t want to use Puzzles, do it in runCode() as suggested in the documentation.
The actual code could be as follows:
function runCode(app, puzzles) { const container = document.getElementById('v3d-container'); const fullscreenToggle = document.getElementById('fullscreen-toggle'); fullscreenToggle.addEventListener('click', () => { if (document.fullscreenElement) { document.exitFullscreen(); } else { if (container.requestFullscreen) { container.requestFullscreen(); // start your game here } } }); }
-
This reply was modified 1 month ago by
Alexander Kovelenov.
-
This reply was modified 1 month ago by
Alexander Kovelenov.
2025-07-26 at 9:48 am #83334c4cc
CustomerWhile I appreciate the suggestion, I’d prefer the user is able to toggle the fullscreen on or off whenever they want while playing the game – using a html element and javascript.
2025-07-26 at 10:59 am #83335Alexander Kovelenov
Staff2025-07-26 at 12:42 pm #83336c4cc
Customerfunction runCode(app, puzzles) { const container = document.getElementById('v3d-container'); const fullscreenToggle = document.getElementById('fullscreen-toggle'); fullscreenToggle.addEventListener('click', () => { if (document.fullscreenElement) { document.exitFullscreen(); } else { if (container.requestFullscreen) { container.requestFullscreen(); // start your game here } } }); }
But this code means I can only activate my app when it’s fullscreen? When app is loaded, I’d like to choose between default small screen, or by fullscreen.
How can I modify the above code to do so?
-
This reply was modified 1 month ago by
c4cc.
2025-07-26 at 1:56 pm #83339Alexander Kovelenov
StaffBut this code means I can only activate my app when it’s fullscreen? When app is loaded, I’d like to choose between default small screen, or by fullscreen.
You can do 2 buttons then. When the user clicks on the “small screen” button you go straight to the app.
2025-07-26 at 4:09 pm #83340c4cc
Customersorry for the noob questions, but
1) as the fullscreen button is in a separate HTML file (in the webpage itself rather than in the verge3d app), I can place
<script src="app.js"></script>
under<script></script>
in HTML file so my app.js file is readable by my webpage’s HTML and back, right?2) if I connect app.js file to my html file like that, do I still have to upload my verge3d project to my webhost as usual after compressing it into a zip file, then place it in my webpage’s iframe element like this?
<div class="gamescreen"><iframe allow="fullscreen" width="100%" height="100%" controls id="gamescreen" frameborder="0" src="https://sitename/myawesomeapp/myawesomeapp.html"></iframe></div>
will the above
<script src="app.js"></script>
affect app usage under the above iframe?3) do I have to put the app.js file into the same place with my HTML files, or leave the app.js file in the app folder where it is zipped and uploaded to webhost? If the former, will it affect user usage, since the app.js containing puzzles is gone now?
-
This reply was modified 1 month, 1 week ago by
-
AuthorPosts
- You must be logged in to reply to this topic.