Expanding the screen size on a HTML page using Mac OS X

How can I replicate the feature on this website:

When clicking on the notebook logo in the top left corner, the page automatically goes into full screen mode on Safari on Mac OS X. How can I implement this feature?

Answer №1

Implementing the functionality of fs.js:


/*global Element */
(function( window, document ) {
    'use strict';

    var keyboardAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element,

        fn = (function() {
            var fnMap = [
                [
                    'requestFullscreen',
                    'exitFullscreen',
                    'fullscreenchange',
                    'fullscreen',
                    'fullscreenElement',
                    'fullscreenerror'
                ],
                [
                    'webkitRequestFullScreen',
                    'webkitCancelFullScreen',
                    'webkitfullscreenchange',
                    'webkitIsFullScreen',
                    'webkitCurrentFullScreenElement',
                    'webkitfullscreenerror'

                ],
                [
                    'mozRequestFullScreen',
                    'mozCancelFullScreen',
                    'mozfullscreenchange',
                    'mozFullScreen',
                    'mozFullScreenElement',
                    'mozfullscreenerror'
                ]
            ],
            i = 0,
            l = fnMap.length,
            ret = {},
            val,
            valLength;

            for ( ; i < l; i++ ) {
                val = fnMap[ i ];
                if ( val && val[1] in document ) {
                    for ( i = 0, valLength = val.length; i < valLength; i++ ) {
                        ret[ fnMap[0][ i ] ] = val[ i ];
                    }
                    return ret;
                }
            }
            return false;
        })(),

        screenfull = {
            isFullscreen: document[ fn.fullscreen ],
            element: document[ fn.fullscreenElement ],

            request: function( elem ) {
                var request = fn.requestFullscreen;

                elem = elem || document.documentElement;

                if ( /5\.1[\.\d]* Safari/.test( navigator.userAgent ) ) {
                    elem[ request ]();
                } else {
                    elem[ request ]( keyboardAllowed && Element.ALLOW_KEYBOARD_INPUT );
                }
            },

            exit: function() {
                document[ fn.exitFullscreen ]();
            },

            toggle: function( elem ) {
                if ( this.isFullscreen ) {
                    this.exit();
                } else {
                    this.request( elem );
                }
            },

            onchange: function() {},
            onerror: function() {}
        };

    if ( !fn ) {
        window.screenfull = null;
        return;
    }

    document.addEventListener( fn.fullscreenchange, function( e ) {
        screenfull.isFullscreen = document[ fn.fullscreen ];
        screenfull.element = document[ fn.fullscreenElement ];
        screenfull.onchange.call( screenfull, e );
    });

    document.addEventListener( fn.fullscreenerror, function( e ) {
        screenfull.onerror.call( screenfull, e );
    });

    window.screenfull = screenfull;

})( window, document );

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"jQuery Hide-and-Seek: A Fun Way to Manip

I am facing a challenge with a set of divs that I need to dynamically show and hide based on user interactions with questions. Essentially, the user will be presented with a question. Based on their answer, specific content with a title and description wi ...

Instructions on how to automatically close a Bootstrap 5 alert without using jQuery

With the removal of jQuery as a dependency in Bootstrap 5, I have been exploring ways to automatically dismiss an Alert after a set duration using raw Javascript. Below is a snippet of my current approach. I believe there is room for optimization or a bett ...

Adjusting the 'Division' Style in HTML

Currently, I am utilizing the incredible StackEdit for my documents. One of its awesome features is the ability to export an HTML file of the document. This document utilizes The default CSS File. As an example, here is the code from the downloaded HT ...

Issue with displaying checkboxes in the dataTable table

I am currently working with dataTables and encountering difficulties displaying checkboxes on my tables. Below is the code that I have: <table id="employeeList" class="table table-sm table-bordered table-hover" cellspacing="0" width="200%"> &l ...

degree of transparency when semi-transparent elements overlap

Imagine you have two <div> elements, one with an opacity of .5 and another overlaying it with the same opacity. What would be the combined opacity of the two? Interestingly, it's not as simple as, .5 × .5 or even, .5 + .5 How can this ...

What is the method for customizing the hover color in a mantine.ui menu?

I've been attempting to modify the menu color when hovering over it, but unfortunately, it's not working. Could anyone provide guidance on how to change the hover color in mantine.ui menu? ...

What is the method for establishing xpath for non-sequential words within a single attribute?

There is a single tag present : <span class="abc pqr and xyz"> I am looking to locate this specific tag in the DOM using xpath. I have attempted the following: //span[contains(@class,'abc pqr')]..... The term 'and' in the cla ...

Tips for stopping variables from leaking in JavaScript

I'm currently working on a JavaScript code for my task manager website. Each page has its own JS file, but I've noticed that the data saved in one file seems to leak over to the others. How can I contain these variables so that tasks don't s ...

Counting the days: how to calculate without using negative numbers

After performing the calculation, the result shows -30. Is there a way to eliminate the negative sign and get 30 instead? $days = (strtotime(date("Y-m-d")) - strtotime($info['expiredate'])) / (60 * 60 * 24) echo abs($days); Any suggestions on ...

What could be causing my HTML table to resize images from left to right?

My latest attempt at creating a simple HTML table involved filling it with placeholder images and spacing them out using a background color. However, the end result was not what I expected: https://i.sstatic.net/kyRil.png Upon closer examination, you&apo ...

Steps to hide a div after it has been displayed once during a user's session

After a successful login, I have a div that displays a success message and then hides after 4 seconds using the following JavaScript code: document.getElementById('success').style.display = 'none'; }, 4000); While this functionality wo ...

Is it advisable to include cursor:pointer in the pseudo class :hover?

Which option is better to use? .myclass { cursor: pointer; } or .myclass:hover { cursor: pointer; } Is there a notable difference between the two? ...

Altering the appearance of an Angular component in real-time by applying various CSS style sheets

I'm currently working on implementing a dynamic style-sheet change for a single-page application using Angular. The concept is to offer users the ability to select from various themes through a dedicated menu. Although only two theme variants are show ...

Angular error TS2339: The property 'before' is not found on type 'HTMLElement' / 'HTMLTextAreaElement' / etc

Objective: My goal is to reposition a div (containing a mat-select dropdown) ABOVE a mat-card-title when the user is accessing the site from a mobile device. If the user is not on a mobile device, the div should remain in its original position to the right ...

Need help inserting an image into the div when the ngif condition is true, and when the ngif condition is false

Essentially, I have a situation where I am using an *ngIf condition on a div that also contains an image. This is for a login page where I need to display different versions based on the type of user. However, I'm facing an issue where the image does ...

Creating a new image by extracting a specific HTML div tag that contains an image and its layers

I currently have a div element that includes an image element along with multiple other div elements containing small text displayed above the image. I am looking to save the image along with its content to a new image file. Any suggestions or ideas are ...

results without a table

Currently, I am working on a search page in PHP and I want to display the results in a similar style to the image provided. Could you please advise on how I can achieve this type of design using CSS? I would like it to be a fluid design using percentages, ...

CSS unable to modify the color of the switch in HTML code

I've been struggling to change the color of the Switch to yellow when it's turned on. Despite my attempts, I haven't been successful in doing so. Is it even possible to achieve this color change? <Switch size="small& ...

The inline $Emit function is not generating the correct random number when using Math.random()

I've been diving into the concept of $emit event in Vue and came across this tutorial: . I tried implementing something similar using Vue2.js, but every time I click the button, it gives me a rounded number instead of a random number like in the guide ...

Navigating through the realm of Android development entails understanding how to manage a multi-object function in JavaScript when using

In order to load an HTML page using the webview component and handle its functions, I am faced with a challenge. The HTML page contains a multi-object named (webkit.messageHandlers.adClicked). How can I utilize the webView.addJavascriptInterface() functi ...