SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: js opera check

  1. #1
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    js opera check

    i've got a script that i'm using to check for standards compliant browsers: ie 5+ and ns 6+. if these aren't present, i'm throwing up a window with browser upgrade instructions. 2 questions here really. how do i check for new versions of opera? and is this code optimized ok? it works so far with ns 4+, ns 6+ and ie 5 and ie 5.5 both on windows and mac.

    Code:
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function browserCheck()
    {
      //check which browser
      var IE5 = (document.all && document.getElementById) ? true : false;
      var NS6 = (document.getElementById && !document.all) ? true : false;
    	
      if(IE5 == false && NS6 == false)
      {
         //call the pop window thingy
         getPopWin('browser.html','popWin','resizable=yes,width=200,height=300');
      }
    }
    
    function getPopWin(theURL,winName,features)
    {
       //set up the pop window thingy
       window.open(theURL,winName,features);
    }
    //-->
    </script>
    i call it here: <body onLoad="browserCheck()">. thanks.

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this might not be what you wanted, but check it out anyway.

    component installed

    PHP Code:
    <HTML xmlns:IE>
    <
    HEAD>
    <
    STYLE>
    @
    media all {
          
    IE\:clientCaps {behavior:url(#default#clientcaps)}
    }
    </
    STYLE>
    </
    HEAD>

    <
    BODY>
    <
    IE:clientCaps ID="oClientCaps" />

    <
    SCRIPT>
        
    bMSvmAvailable oClientCaps.isComponentInstalled("{89820200-ECBD-11CF-8B85-00AA005B4383}",
        
    "ComponentID");

    document.write(bMSvmAvailable);
    </SCRIPT> 
    component list

    Address Book {7790769C-0471-11D2-AF11-00C04FA35D02}
    Windows Desktop Update NT {89820200-ECBD-11CF-8B85-00AA005B4340}
    DirectAnimation {283807B5-2C60-11D0-A31D-00AA00B92C03}
    DirectAnimation Java Classes {4F216970-C90C-11D1-B5C7-0000F8051515}
    DirectShow {44BBA848-CC51-11CF-AAFA-00AA00B6015C}
    Dynamic HTML Data Binding {9381D8F2-0288-11D0-9501-00AA00B911A5}
    Dynamic HTML Data Binding for Java {4F216970-C90C-11D1-B5C7-0000F8051515}
    Internet Connection Wizard {5A8D6EE0-3E18-11D0-821E-444553540000}
    Internet Explorer 5 Web Browser {89820200-ECBD-11CF-8B85-00AA005B4383}
    Internet Explorer Classes for Java {08B0E5C0-4FCB-11CF-AAA5-00401C608555}
    Internet Explorer Help {45EA75A0-A269-11D1-B5BF-0000F8051515}
    Internet Explorer Help Engine {DE5AED00-A4BF-11D1-9948-00C04F98BBC9}
    Windows Media Player {22D6F312-B0F6-11D0-94AB-0080C74C7E95}
    NetMeeting NT {44BBA842-CC51-11CF-AAFA-00AA00B6015B}
    Offline Browsing Pack {3AF36230-A269-11D1-B5BF-0000F8051515}
    Outlook Express {44BBA840-CC51-11CF-AAFA-00AA00B6015C}
    Task Scheduler {CC2A9BA0-3BDD-11D0-821E-444553540000}
    Microsoft virtual machine {08B0E5C0-4FCB-11CF-AAA5-00401C608500}
    component request

    PHP Code:
    <HTML xmlns:IE>
    <
    HEAD>
    <
    STYLE>
    @
    media all {
          
    IE\:clientCaps {behavior:url(#default#clientCaps)}
    }
    </
    STYLE>

    <
    SCRIPT>

       var 
    bDBAvailable  false;
       var 
    sDBVersion '';
       var 
    sDBID "{9381D8F2-0288-11D0-9501-00AA00B911A5}"
       
       
    bDBAvailable oClientCaps.isComponentInstalled(sDBID,"componentid");
       
    document.write(bDBAvailable)
       
    // if data binding is unavailable, install it
       
    if (!bDBAvailable)
       {
          
    oClientCaps.addComponentRequest(sDBID"componentid");
          
    bDBAvailable oClientCaps.doComponentRequest();

       }

    </SCRIPT>
    </HEAD>

    <BODY BGCOLOR="#FFFFFF">
       <IE:clientCaps ID="oClientCaps" />
    </BODY> 

    compare versions


    PHP Code:
    <HTML xmlns:IE>
    <
    HEAD>
    <
    STYLE>
    @
    media all {
          
    IE\:clientCaps {behavior:url(#default#clientcaps)}
    }
    </
    STYLE>
    </
    HEAD>

    <
    BODY>
    <
    IE:clientCaps ID="oClientCaps" />

    <
    SCRIPT>
        
    sMSvmVersion oClientCaps.getComponentVersion("{08B0E5C0-4FCB-11CF-AAA5-00401C608500}",
        
    "ComponentID"); 
    document.write(sMSvmVersion);
    </SCRIPT>   

    </BODY> 
    download

    PHP Code:
    <HTML XMLNS:IE>

    <
    SCRIPT LANGUAGE="VBScript">
        Function 
    onDownloadDone(s
            
    MsgBox s
        End 
    Function
    </SCRIPT>

    <IE:DOWNLOAD ID="oDownload" STYLE="behavior:url(#default#download)" />

    <button 
    onclick="vbscript:oDownload.startDownload 'downloadvb.html', GetRef('onDownloadDone')">
    Download File</button> 

  3. #3
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Opera 6 IS a standards compliant browser (although its DOM support still has a little way to go). Also, using a javascript popup window to talk to users with older browsers isn't going to work as the browsers you want to avoid are far more likely not to have javascript support!

    Why are you trying to warn people off in the first place? What features are you implementing on your site that older browsers will not be able to access?

    That said, your code can be shortened like this:
    Code:
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function browserCheck() {
      if (!document.all && !document.getElementById) {
        window.open('browser.html','popWin','resizable=yes,width=200,height=300');
      }
    }
    //-->
    </script>
    The logic is slightly different but the end effect should be the same.

  4. #4
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this thread is my rant on the browser usage at one of my sites. 2/3 of the users last week were using substandard browsers. take a look and you'll see what i mean.

    i don't have a lot of features that i'm using except CSS. i've gotten a few e-mails from people with way old browsers who said they couldn't read the page. i realize that someone with js turned off won't see the pop up and i thought about using a css thing, ie: display = none, and place a message about upgrading on the page somewhere. may still yet - not sure.

    I knew Opera 6 was compliant, just couldn't figure out how to check for it, which was my original question.

    by the way: thanks for the code guys!
    Last edited by bbolte; Jun 4, 2002 at 11:19.


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
  •