Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Browser detection problem

    I've got a pop-up WMP that works ok in IE but my detection code isn't helping me with the other browsers. Any suggestions are appreciated.

    This is my JS file:

    Code:
    function PlayerOpen() {
    
    var visitorOS=0
    var UniqueID=0
    var objTypeTag=0
    PlayWin = window.open('',UniqueID,'width=320,height=190,top=0' + ',left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
    PlayWin.focus(); 
    
    var isWin = navigator.userAgent.toLowerCase().indexOf("windows") != -1;
       if (isWin) { // Use MIME type application/x-mplayer2
          visitorOS="Windows";
            }
        else  { // Use MIME type audio/mpeg, audio/x-wav, etc.
          visitorOS="Other";
           }
    
    var objTypeTag = "application/x-mplayer2"; // MIME type for non-IE browsers on Windows
      if (visitorOS != "Windows") { objTypeTag = "audio/x-ms-wma"}; // MIME type for Linux & Mac 
      var winContent = "<HTML><HEAD><TITLE> Sturtevant Technical Services </TITLE></HEAD><BODY bgcolor='#FF9900'>";
          winContent += "<B style='font-size:14px;font-family:Verdana,sans-serif;line-height:1.5'><DIV ALIGN='CENTER'+";      
          winContent += ">Sturtevant Technical Services</DIV></B>";
          winContent += "<OBJECT id='mediaPlayer' width='300' height='69'";
          winContent += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'";
          winContent += "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'";
          winContent += "standby='Loading Microsoft Windows Media Player components...' type='objTypeTag'>";
          winContent += "<param name='fileName' value='http://www.sturtevantfan.com/Audio/sturtevantaudio.asx'>";
          winContent += "<param name='animationatStart' value='1'>";
          winContent += "<param name='ShowStatusBar' value='1'>"; 
          winContent += "<param name='transparentatStart' value='1'>";
          winContent += "<param name='autoStart' value='1'>";
          winContent += "<param name='showControls' value='1'>";
          winContent +=  "<param name='loop' value='0'>";
          winContent += "<EMBED type='objTypeTag'>";
          winContent += "pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'";
          winContent += "id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'";
          winContent += "bgcolor='darkblue' showcontrols='true' showtracker='-1'"; 
          winContent += "showdisplay='0' showstatusbar='1' videoborder3d='-1' width='300' height='69'";
          winContent += "src='http://www.sturtevantfan.com/Audio/sturtevantaudio.asx' autostart='true' designtimesp='5311' loop='false'>";
          winContent += "</EMBED>";
    winContent += "</OBJECT>";
    winContent += "</td></tr>";
    winContent += "<FORM><DIV align='center'><INPUT type='button' value='Close this window'+"; 
    winContent += "onClick='javascript:window.close();'></DIV></FORM>";
    winContent += "</BODY></HTML>";
    PlayWin.document.write(winContent);
    PlayWin.document.close(); 
    }

  • #2
    New to the CF scene
    Join Date
    Aug 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh(( I've got the same problem(

  • #3
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Shouldn't this be in the Javascript section.
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,695
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    This should be in the garbage can (dustbin). If you can’t write code that works in all browsers then you shouldn’t develop websites at all.

    JavaScript browser detection things are making me aggressive because that’s the most amateurish approach there is (and looking at the code above makes me even more aggressive because I can’t stand the crap that circulates on the internet). I’m only gonna give you this much of a hint: Check for the support of certain methods or objects, not for browsers or operating systems (even worse: with JavaScript, which can be disabled or not available at all in the first place).

    Ideally you would provide a non-proprietary file format that all browsers support or check for the support of a certain format or MIME type or whatever and provide the media based on that support. Likewise you’d use some variation of the Flash Satay to embed external media and scrap the old embed kind of way. Alternatively you could use Flash which is supported by and installed in many browsers in many OSs.
    Last edited by VIPStephan; 08-07-2009 at 06:27 PM.


  •  

    Posting Permissions

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