'Activate Full Screen when entering/refreshing page [duplicate]

I have a slider project that needs full screen to work on a smart tv. There is a button with onClick="requestFullScreen", but every time i need to update the page on Github, i need to refresh the screen and click the button.

So i thought, there is a way to refresh automatically using: <meta http-equiv='refresh' content='seconds'>.

But how can i activate full screen when entering/refreshing the page?



Solution 1:[1]

You can use the load event to run some code whenever the page is loading (which will also trigger when you refresh the page). Example:

window.onload = function() {
  document.documentElement.requestFullscreen();
}

Solution 2:[2]

You could try and pass a pointer to an array, as an example:

class B
{
public:
    B(int* arr, const size_t len)
    {
        // Bad way:
        // this->arr = arr;
        // this->len = len;
        
        // Better:
        this->arr = new int[len];
        this->len = len;
        
        for (int i = 0; i < len; i++)
        {
            this->arr[i] = arr[i];
        }
    }

    ~B()
    {
        // Don't forget to free unused dynamic memory:
        delete[] this->arr;
    }
    
    void printArray() const 
    {
        for (int i = 0; i < this->len; i++)
        {
            std::cout << this->arr[i] << " ";
        }
        
        std::cout << std::endl;
    }
    
    int* arr;
    size_t len;
};


int main()
{
    int* arr = new int[10];
    
    for (int i = 0; i < 10; i++)
    {
        arr[i] = i + 1;
    }
    
    B b(arr, 10);
    
    b.printArray();
    
    delete[] arr;

    return 0;
}

But the problem is that it's not memory safe and not so useful since CPP's standard library provides better solutions. For example, you might use std::vector

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Pierre Demessence
Solution 2 Ovid