Advanced Search

Results 1 to 3 of 3

Thread: Button using JS with functionality of F11 keyboard key

  1. #1
    Join Date
    Mar 2012
    Posts
    53
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Button using JS with functionality of F11 keyboard key

    Hi,
    I want to make a button which if pressed works as if F11 key on keyboard is pressed.
    For button html would be like this (I think)

    <button type="button" onclick="some function">FullScreen</button>

    Now I don't know what function would go in that onclick as I don't have the JS. One more thing that would be nice if the text 'FULLSCREEN' changes to 'NORMAL WINDOW' when the button is pressed, so that the user could realize that they have to press the same button again to get out of fullscreen, it would be like toggle at every click text changes from 'FULLSCREEN' to 'NORMAL WINDOW' and then if pressed again changing to 'FULLSCREEN'.

  2. #2
    Join Date
    Mar 2012
    Posts
    53
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Avocarto View Post
    I'm new here , nice thread!
    Welcome to dynamic drive

  3. #3
    Join Date
    Apr 2012
    Location
    Chester, Cheshire
    Posts
    329
    Thanks
    7
    Thanked 35 Times in 35 Posts

    Default

    Try something like:

    PHP Code:

    // JavaScript Code:

    function toggleFullScreenMode() {
        var 
    btn document.getElementById'btnFullScreenToggle' );
        if ( 
    btn.value == 'goFull' ) {
            var 
    widthFullScreen screen.availWidth;
            var 
    heightFullScreen screen.availHeight;

            
    window.openwindow.location.href'',
                
    'toolbar=no,' +
                
    'location=no,' +
                
    'directories=no,' +
                
    'status=no,' +
                
    'menubar=no,' +
                
    'scrollbars=1,' +
                
    'resizable=no,' +
                
    'copyhistory=1,' +
                
    'width=' widthFullScreen ',' +
                
    'height=' heightFullscreen ',' +
                
    'top=0,' +
                
    'left=0'
            
    ,'replace' );
            
    btn.value 'goNormal';
            
    btn.innerHTML 'Normal Mode';
        } else if ( 
    btn.value == 'goNormal' ) {
            
    window.openwindow.location.href'','','replace' );
            
    btn.value 'goFull';
            
    btn.innerHTML 'Full Screen Mode';
        }

    PHP Code:

    // HTML Code:

    <button name="btnFullScreenToggle" id="btnFullScreenToggle" type="submit" value="goFull" onclick"toggleFullScreenMode();">Full Screen Mode</button
    Last edited by ApacheTech; 05-01-2012 at 08:32 PM.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •