Need help in JavaScript!

Discussion in 'JavaScript' started by iNfans, Jan 23, 2007.

  1. #1
    Hi guys! I have this script, which is working in IE but not working in FireFox browsers. The line commented "first" in script opens embeded wm player in fullscreen when user click on
    <a href="#" onclick="fullscr();return false;">
    Code (markup):
    link. The lines commented "second" resizes browser window and player screen, when user click on
    <a href="#" onClick="resizeMe();"
    Code (markup):
    link. As I say, those two scripts works perfectly on IE, but they didnt work in FireFox browser. Can enyone fix this script PLEASE!

    The script:
    <script language=JavaScript>
    
    ///---------------FIRST--------------////
    function fullscr(){mediaPlayer.displaySize=3;return true;}
    ///---------------END_FIRST--------------////
    
    ///---------------SECOND--------------////
    var size=1;
    window.focus();
    function resizeMe() {
    if(size==1) {
        size=2;
        window.resizeTo(435,575);
        mediaPlayer.width=375;
        mediaPlayer.height=350;
    } else {
        size=1;
        window.resizeTo(595,735);
        mediaPlayer.width=555;
        mediaPlayer.height=505;
        }
    }
    ///---------------END_SECOND--------------////
    </script>
    
    <OBJECT ID='mediaPlayer' width='555' height='505' CLASSID='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' CODEBASE='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' STANDBY='Loading Microsoft Windows Media Player components...'  TYPE='application/x-oleobject'>
     <PARAM NAME='FileName' VALUE='url'>
     <PARAM NAME='ShowStatusBar' VALUE='1'>
     <PARAM NAME='AutoSize' VALUE='-1'>
     <PARAM NAME='uiMode' VALUE='mini'>
     <PARAM NAME='AutoStart' VALUE='1'>
     <PARAM NAME='AllowScan' VALUE='1'>
     <PARAM NAME='AllowChangeDisplaySize' VALUE='-1'>
     <PARAM NAME='BufferingTime' VALUE='3'>
     <PARAM NAME='DisplayMode' VALUE='0'>
     <PARAM NAME='DisplaySize' VALUE='4'>
     <PARAM NAME='Enabled' VALUE='-1'>
     <PARAM NAME='EnableContextMenu' VALUE='0'>
     <PARAM NAME='EnablePositionControls' VALUE='-1'>
     <PARAM NAME='EnableFullScreenControls' VALUE='1'>
     <PARAM NAME='EnableTracker' VALUE='-1'>
     <PARAM NAME='SendOpenStateChangeEvents' VALUE='-1'>
     <PARAM NAME='SendWarningEvents' VALUE='-1'>
     <PARAM NAME='SendErrorEvents' VALUE='-1'>
     <PARAM NAME='SendKeyboardEvents' VALUE='0'>
     <PARAM NAME='SendMouseClickEvents' VALUE='0'>
     <PARAM NAME='SendMouseMoveEvents' VALUE='0'>
     <PARAM NAME='SendPlayStateChangeEvents' VALUE='-1'>
     <PARAM NAME='ShowControls' VALUE='1'>
     <PARAM NAME='ShowAudioControls' VALUE='1'>
     <PARAM NAME='ShowDisplay' VALUE='0'>
     <PARAM NAME='ShowGotoBar' VALUE='0'>
     <PARAM NAME='ShowPositionControls' VALUE='0'>
     <PARAM NAME='ShowTracker' VALUE='0'>
     <EMBED src='url' type='application/x-mplayer2' ID='mediaPlayer' width='550' height='500' controller='true' scale='tofit' kioskmode='true' BGCOLOR='#000000' ShowStatusBar='1' AutoSize='-1' autostart='true' AllowScan='1' AllowChangeDisplaySize='-1' BufferingTime='3' DisplayMode='0' DisplaySize='4' Enabled='-1' EnableContextMenu='0' EnablePositionControls='-1' EnableFullScreenControls='1' EnableTracker='-1' SendOpenStateChangeEvents='-1' SendWarningEvents='-1' SendErrorEvents='-1' SendKeyboardEvents='0' SendMouseClickEvents='0' SendMouseMoveEvents='0' SendPlayStateChangeEvents='-1' ShowControls='1' ShowAudioControls='1' ShowDisplay='0' ShowGotoBar='0' ShowPositionControls='0' ShowTracker='0'></EMBED>
     </OBJECT>
    
    <a href="#" onclick="fullscr();return false;">Fullscreen</a>
    <a href="#" onClick="resizeMe();">Resize</a>
    Code (markup):
     
    iNfans, Jan 23, 2007 IP
  2. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #2
    You need to use the standard W3C to access mediaPlayer: document.getElementById('mediaPlayer')
    So you'll need:
    ///---------------FIRST--------------////
    function fullscr(){ document.getElementById('mediaPlayer').displaySize=3;return true;}
    ///---------------END_FIRST--------------////
    
    ///---------------SECOND--------------////
    var size=1;
    window.focus();
    function resizeMe() {
    mp= document.getElementById('mediaPlayer');	
    if(size==1) {
        size=2;
        window.resizeTo(435,575);
        mp.width=375;
        mp.height=350;
    } else {
        size=1;
        window.resizeTo(595,735);
        mp.width=555;
        mp.height=505;
        }
    }
    ///---------------END_SECOND--------------////
    Code (markup):
    TIP: You can see your errors on javascript console window (under Tools/Javascript console Menu).
     
    ajsa52, Jan 23, 2007 IP
  3. iNfans

    iNfans Well-Known Member

    Messages:
    160
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Thank you ajsa52 very much for help. I tried to fix like you say but it still not work in firefox.. Any ideas?
     
    iNfans, Jan 24, 2007 IP
  4. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #4
    If you're asking about why the Media Player not displaying on Firefox, I guess the problem is because you're using an ActiveX control (Microsoft propietary code) on your "mediaPlayer" object.
     
    ajsa52, Jan 24, 2007 IP
  5. iNfans

    iNfans Well-Known Member

    Messages:
    160
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #5
    Media Player is displaying and playng in FireFox, but not resizing by this script.
     
    iNfans, Jan 24, 2007 IP
  6. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #6
    For me is not displaying/playing on Firefox, maybe I don't have installed the required plugin.
    But for me, resizing is working this way: alternating small and medium size. Full screen does not work because you're setting displaySize=3, but you're not calling window.resizeTo on fullscr function.
     
    ajsa52, Jan 24, 2007 IP
  7. iNfans

    iNfans Well-Known Member

    Messages:
    160
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #7
    It seems that there's no solution for my trouble.. :-(
     
    iNfans, Jan 24, 2007 IP
  8. iNfans

    iNfans Well-Known Member

    Messages:
    160
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #8
    Thank you anyway ajsa52 !
     
    iNfans, Jan 24, 2007 IP