BrowserFullscreenScript for TWC - now partly working.

49 views
Skip to first unread message

Jan

unread,
Apr 20, 2015, 10:15:32 AM4/20/15
to TiddlyWiki
Hello,
the button I did in .js is now partly working,
it can change the browser into Fullscreen

three Problems are not solved yet.

-In Fullscreenmode the button switches to Exit Fullscreen after it is
clicked a second time.
-Either the ToggleBrowserFullscreen or the exitFullscreen function does
not work.
-How can I get the browser to remember my decision to allow Fullscreen?

I hope someone can help me on this.



!Button
<script label="Fullscreen">

//looks if the Browser is Fullscreenenabled
var fullscreenEnabled = document.fullscreenEnabled ||
document.mozFullScreenEnabled || document.webkitFullscreenEnabled;
//looks if the document is already in Fullscreen.
var fullscreenElement = document.fullscreenElement ||
document.mozFullScreenElement || document.webkitFullscreenElement;
//defines a function that will exit Fullscreen if the dokument is in
Fullscreen and otherwise go into fullscreen with the browserspecific
term, calling F11 as last option.
//defines a browserspecific EXITFullscreen function
function exitFullscreen()
{
if(document.exitFullscreen)
{
document.exitFullscreen();
}
else if(document.mozCancelFullScreen)
{
document.mozCancelFullScreen();
}
else if(document.webkitExitFullscreen)
{
document.webkitExitFullscreen();
}
}
//defines a browserspecific ENTERFullscreen function
function goFullscreen(element)
{
if(element.requestFullscreen)
{
element.requestFullscreen();
}
else if(element.mozRequestFullScreen)
{
element.mozRequestFullScreen();
}
else if(element.webkitRequestFullscreen)
{
element.webkitRequestFullscreen();
}
else if(element.msRequestFullscreen)
{
element.msRequestFullscreen();
}
}
goFullscreen(document.documentElement)
// This Function decides which Function should be used
function toggleBrowserFullscreen(fullscreenEnabled,fullscreenElement)
{
if(fullscreenElement)
{
exitFullscreen()
}
else if(fullscreenEnabled)
{
goFullscreen(document.documentElement)
}
else
{
SendKeys("{F11}") // ancient brute force method to toggle Fullscreen.
}
}
//create a button which is telling what will be done.
place.innerHTML=fullscreenElement?"Exit Fullscreen":"Fullscreen";
toggleBrowserFullscreen(document.documentElement);

</script>

Eric Shulman

unread,
Apr 21, 2015, 6:11:49 AM4/21/15
to tiddl...@googlegroups.com
On Monday, April 20, 2015 at 7:15:32 AM UTC-7, Jan wrote:
Hello,
the button I did in .js is now partly working

try this:
<script label="Fullscreen">


function exitFullscreen() {
   
if     (document.exitFullscreen)       document.exitFullscreen();

   
else if(document.mozCancelFullScreen)  document.mozCancelFullScreen();
   
else if(document.webkitExitFullscreen) document.webkitExitFullscreen();
}


function goFullscreen(element) {
   
if(element.requestFullscreen)            element.requestFullscreen();
   
else if(element.mozRequestFullScreen)    element.mozRequestFullScreen();
   
else if(element.webkitRequestFullscreen) element.webkitRequestFullscreen();
   
else if(element.msRequestFullscreen)     element.msRequestFullscreen();
}


var fullscreenEnabled = document.fullscreenEnabled || document.mozFullScreenEnabled || document.webkitFullscreenEnabled;
var fullscreenElement = document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement;


if     (fullscreenElement) exitFullscreen()
else if(fullscreenEnabled) goFullscreen(document.documentElement)
else                       SendKeys("{F11}"); // ancient brute force method to toggle Fullscreen.



place
.innerHTML=fullscreenElement?"Fullscreen":"exit Fullscreen";
</script>  

-e

Jan

unread,
Apr 21, 2015, 8:48:24 PM4/21/15
to tiddl...@googlegroups.com
Hi Eric,
Now it is working beautifully.
Jan
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/4a8d7738-649a-4e6c-b64c-ec0990bae9e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages