SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Location
    U.S.A
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript and Determine Browser Help

    Hey,

    I am trying to right some javascript that only shows if the user is using Internet Explorer or an internet explorer bassed browser. Not sure why it's not working. The code is below. Yes only for ie browser, nothing else. Since my code only works in ie anyways, unless someone can figure out how to make it work in all browsers.

    I know the button code is fine for all browsers since it shows up in all browsers but the javascript does not work in all browsers.

    Thanks for you help,
    Will

    Code:
     
    <INPUT TYPE=BUTTON VALUE="Check Spelling"
    onclick='checkspell()'>
    <SCRIPT Language="Javascript">
    var myAgent = navigator.userAgent.toLowerCase();
    var myVersion = parseInt(navigator.appVersion);
    var is_ie = ((myAgent.indexOf("msie") != -1) &&
    (myAgent.indexOf("opera") == -1));
    var is_nav = ((myAgent.indexOf('mozilla')!=-1) &&
    (myAgent.indexOf('spoofer')==-1)
    && (myAgent.indexOf('compatible') == -1) &&
    (myAgent.indexOf('opera')==-1)
    && (myAgent.indexOf('webtv') ==-1) &&
    (myAgent.indexOf('hotjava')==-1));
    var is_win = ((myAgent.indexOf("win")!=-1) ||
    (myAgent.indexOf("16bit")!=-1));
    var is_mac = (myAgent.indexOf("mac")!=-1);
    function checkspells() {
    try {
     var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
     document.write("&nbsp;<input type='button' name='btnSpell' value='Check Spelling' onclick='checkspell()'>");
    }
    catch(exception) {
     if (is_ie&&is_win) {
      document.write("&nbsp;<input type='button' name='btnSpell' value='Get ieSpell' onclick='checkspell()'>");
     }
    }
    }
    function checkspell() {
    try {
     var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
     tmpis.CheckAllLinkedDocuments(document);
    }
    catch(exception) {
     if (is_ie&&is_win) {
      window.open("http://www.iespell.com/download.php","DownLoad");
     }
    }
    }
    </SCRIPT>
    God Bless America

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Location
    U.S.A
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, is there an easy way to change the button text if the user is using ie but does not have iespell installed. Meaning if they do and iespell is installed it then works and says spell checking. But if they dont have it installed the it says Enable Spell Checking. Thats only if they are using ie.

    And if they are not using ie, no matter if its install or not then it just hides the button all together.

    Thats if no one can figure out how to make it work in other non ie browsers like opera, etc.

    Thanks again,
    Will
    God Bless America

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Location
    U.S.A
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now I figured out how to send users to a different site if they are not using ie and click the button. But how about just making the button say something else.

    Now this does work good enough because i can just send the users to anysite i want. But I would rather just either hide the button or make the button say something different. Trying to figure that out but dont know how to display different buttons or dialong boxes.

    See:

    Code:
     
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE=BUTTON VALUE="Check Spelling" tabindex='4'onclick='checkspell()' class='forminput'>
    <SCRIPT Language="Javascript">
    browsername=navigator.appName;
    if (browsername.indexOf("Netscape")!=-1) {browsername="NS"}
    else
    {if (browsername.indexOf("Microsoft")!=-1) {browsername="MSIE"}
    else {browsername="N/A"}};
    function checkspell() {
    try {
     var tmpis = new ActiveXObject("ieSpell.ieSpellExtension");
     tmpis.CheckAllLinkedDocuments(document);
    }
    catch(exception) {
     if (browsername=="MSIE"){
      window.open("http://www.iespell.com/download.php","DownLoad");
     }
    }
    if (browsername=="N/A") {window.location="notie.html"};
    }
    </SCRIPT>
    God Bless America


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
  •