SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Ajax wont work with DOCTYPE, but works in IE. Free lunch inside

    I have a script that refuses to run in Firefox unless I remove the DOCTYPE. Could someone please help me here. I will buy you lunch via PayPal if you can help me.

    index.php
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
    <title>Web Hosting, Domain Host, Email Hosting </title>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
    <link rel="shortcut icon" href="/favicon.ico" />
    <link rel="stylesheet" type="text/css" href="css/styles.css" />
    </head>
    <body onLoad="document.pf.domain.focus();">
    <!-- begin header -->
    <div id="hdrTop"></div>
    <div id="hdrContainer">
      <div id="navLogo"><a href="./"><img src="images/logo.jpg" alt="Web Hosting" width="328" height="50" /></a></div>
      <div id="navStatus"> <img src="images/iconArrowBlue.gif" />&nbsp;<a href="secure/client_area/">Client Area</a><br />
        <img src="images/iconArrowBlue.gif" />&nbsp;<a href="hosting_support_desk/index.php">Support Desk</a><br />
        <img src="images/iconArrowBlue.gif" />
        <!-- Begin SupportSuite Javascript Code -->
       
        <!-- End SupportSuite Javascript Code -->
      </div>
      <div id="navSearch"> <img src="images/toll_free.gif" /> </div>
      <div class="clear">
        <!-- -->
      </div>
    </div>
    <!-- end header -->
    <div id="home_bannerContainer" style="position: relative; top: 0px; left: 0px;">
      <div class="banner_menu">
        <li class="banner_menu"><a href="index.php">Home</a></li>
        <li class="banner_menu"><a href="main/why_levelserve_hosting">Why Us</a></li>
        <li class="banner_menu"><a href="main/shared_webhosting">Shared</a></li>
        <li class="banner_menu"><a href="main/dedicated_servers">Dedicated</a></li>
        <li class="banner_menu"><a href="main/mutlisite_web_hosting">Mutli Site</a></li>
        <li class="banner_menu"><a href="main/reseller_webhosting">Resellers</a></li>
        <li class="banner_menu"><a href="main/hosting_testimonials">Testimonials</a></li>
        <li class="banner_menu"><a href="main/FAQ">FAQ</a></li>
        <li class="banner_menu"><a href="main/web_hosting_affiliates">Domains</a></li>
        <li class="banner_menu"><a href="forum/forumdisplay.php?f=3">News</a></li>
        <li class="banner_menu"><a href="forum/">Community Forum</a></li>
      </div>
      <div class="banner_text">  is your smartest choice in hosting. We approach the hosting industry with goals to be the best and raise the bar. Our support staff is employed to make you happy. Hosting companies are everywhere and super cheap plans start at $1.00 a month. Such companies are often a bad choice. At    we provide great service, great prices, and great support. If you are serious about your hosting, then choose a company serious about you. </div>
    </div>
    <!-- begin full-width page container -->
    <div id="container_home">
      <!-- begin welcome -->
      <div id="under_banner_ads">
        <div id="shared">
          <h2><a href="main/index.php?categoryid=10"><img src="images/shared_hosting.gif" alt="Shared Web Hositng" /></a></h2>
          <ul style="margin-bottom: 0; ">
            <li><a href="main/index.php?categoryid=10">Plans starting at $5.00 </a></li>
            <li><a href="main/index.php?categoryid=10">Unlimited Email </a></li>
            <li><a href="main/index.php?categoryid=10">Automated Backups </a></li>
            <li><a href="main/index.php?categoryid=10">cPanel </a></li>
            <li><a href="main/index.php?categoryid=10">No Overloaded Servers </a></li>
          </ul>
        </div>
        <div id="dedicated">
          <h2><a href="main/index.php?categoryid=11"><img src="images/dedicated_hosting.gif" alt="Dedicated Servers" /></a></h2>
          <ul style="margin-bottom: 0;">
            <li><a href="main/index.php?categoryid=11">Windows and Linux</a></li>
            <li><a href="main/index.php?categoryid=11">$0 Setup Fee</a></li>
            <li><a href="main/index.php?categoryid=11">1000 Mbps Ports</a></li>
            <li><a href="main/index.php?categoryid=11">Remote Reboot</a></li>
            <li><a href="main/index.php?categoryid=11">DDOS Protecion</a></li>
          </ul>
        </div>
        <div id="multisite">
          <h2><a href="main/index.php?categoryid=12"><img src="images/multi_site_hosting.gif" alt="Multi Site Hosting" /></a></h2>
          <ul style="margin-bottom: 0;">
            <li><a href="main/index.php?categoryid=12">Plans Starting at $20</a></li>
            <li><a href="main/index.php?categoryid=12">Host Multiple Sites</a></li>
            <li><a href="main/index.php?categoryid=12">Control Sites Independently</a></li>
            <li><a href="main/index.php?categoryid=12">Master Control Panel</a></li>
            <li><a href="main/index.php?categoryid=12">Divide Resources</a></li>
          </ul>
        </div>
        <div id="reseller">
          <h2><a href="main/index.php?categoryid=13"><img src="images/reseller_hosting.gif" alt="Latest News" /></a></h2>
          <ul style="margin-bottom: 0;">
            <li><a href="main/index.php?categoryid=13">Plans Starting at $20</a></li>
            <li><a href="main/index.php?categoryid=13">Unlimited Domains</a></li>
            <li><a href="main/index.php?categoryid=13">Custom Nameservers</a></li>
            <li><a href="main/index.php?categoryid=13">Fully Managed</a></li>
            <li><a href="main/index.php?categoryid=13">WHM/Cpanel/DirectAdmin</a></li>
          </ul>
        </div>
      </div>
      <div class="clear"> </div>
      <div>
      <script language="javascript" src="domains/s.js"></script>
    <div align="center">
      <table border="0" cellpadding="2" width="757" cellspacing="2">
        
        <tr>
          <td><table border="0" cellpadding="0" width="100&#37;" cellspacing="0" height="184">
              
              <tr>
                <td width="90%" valign="top">&nbsp;</td>
              </tr>
              <tr>
                <td valign="top" align="center"><table border="1" cellpadding="0" cellspacing="0" width="100%" class="tooltop" style="border-collapse: collapse">
                    <tr>
                      <td><form name="pf">
                          <table border="0" cellpadding="3" style="border-collapse: collapse" cellspacing="3" width="100%">
                            <tr>
                              <td><font size="2"><b>Check a domain name </b></font></td>
                              <td  align="right"><font style="font-size: 8pt"> (Do not enter domain extension)</font></td>
                            </tr>
                            <tr>
                              <td  colspan="2"><input onKeyDown="if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) { sp(); return false; }" type="text" name="domain" size="70" onKeyUp="sp();" style="border:1px solid #213D6B; height: 35; width: 100%; font-size: 18pt; margin:0px; padding-left:5px; padding-top:2px; padding-right:5px; background-color:#FFFFFF"></td>
                            </tr>
                            <tr>
                              <td  colspan="2"><font face="Verdana"> <font size="2">Check for domains ending with </font> <font color="#FFFFFF" size="3">
                                <select size="1" onChange="ld='';sp();" name="one">
                                  <option value="com" selected>.com</option>
                                  <option value="net">.net</option>
                                  <option value="info">.info</option>
                                  <option value="org">.org</option>
                                  <option value="us">.us</option>
                                </select>
                                </font><font size="2">&nbsp; and </font> <font color="#FFFFFF" size="3">
                                <select size="1" onChange="ld='';sp();" name="two">
                                  <option value="com">.com</option>
                                  <option value="net" selected>.net</option>
                                  <option value="info">.info</option>
                                 <option value="org">.org</option>
                                  <option value="us">.us</option>
                                </select>
                              </font></font></td>
                            </tr>
                          </table>
                        </form></td>
                    </tr>
                  </table></td>
              </tr>
              <tr>
                <td valign="top">&nbsp;</td>
              </tr>
              <tr>
                <td valign="top"><table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                      <td width="357"><table border="1" cellpadding="5" style="border-collapse: collapse" width="100%" cellspacing="5" height="250" bordercolor="#C0C0C0">
                          <tr>
                            <td  valign="top"><div id="pdiv"><b> <font size="2">Enter your domain into the box above and results should appear.</font></b></div>
                              <br>
                            <div id="pdivtwo">&nbsp;</div></td>
                          </tr>
                        </table></td>
                      <td width="4">&nbsp;</td>
                      <td><table border="1" cellpadding="5" style="border-collapse: collapse" width="100%" cellspacing="5" height="250" bordercolor="#C0C0C0">
                          <tr>
                            <td  valign="top"><div id="psuggest"> <font size="2"> Suggestions for your keyword will appear here.</font></div></td>
                          </tr>
                        </table></td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
        </tr>
      </table>
    </div>
      </div>
      <div class="clear"> </div>
    </div>
    <div> </div>
    
      <!-- -->
    </div>
    <!-- end footer -->
    </body>
    </html>
    and the js
    Code:
     var nc; function addBookmark() { if (window.domaincart && window.sidebar.addPanel) { window.sidebar.addPanel("Domain Check","../domains/",''); } else if ( window.external && (navigator.platform=='Win32' || (window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1)) ) { window.external.AddFavorite("../domains/","LS"); } else if (document.layers) { window.alert('Please click OK then press Ctrl+D to create a bookmark'); } else { window.alert('Please use your browser\'s bookmarking facility to create a bookmark'); } return false; } var t=0; var ld=0; function createXMLHttpRequest() { var ua; if(window.XMLHttpRequest) { try { ua = new XMLHttpRequest(); } catch(e) { ua = false; } } else if(window.ActiveXObject) { try { ua = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { ua = false; } } return ua; } var reqsuggest = createXMLHttpRequest(); var req = createXMLHttpRequest(); var reqtwo = createXMLHttpRequest(); function sendRequest(domain,ext,type) { if (!t) { return false; } domain = domain.replace('&',"%26"); if (type==2) { t = 0; reqsuggest.open('post', '../instant/s.php?domain='+domain); reqsuggest.onreadystatechange = handleResponsesuggestion; reqsuggest.send(null); } if (type == 1) { req.open('get', '../domains/g.php?ext='+ext+'&domain='+domain); req.onreadystatechange = handleResponse; req.send(null); } if (type == 2) { reqtwo.open('get', '../domains/g.php?ext='+ext+'&domain='+domain); reqtwo.onreadystatechange = handleResponsetwo; reqtwo.send(null); } } function handleResponsesuggestion() { if(reqsuggest.readyState == 4){ var response = reqsuggest.responseText; document.all.psuggest.innerHTML=response; } } function handleResponse() { if(req.readyState == 4){ var response = req.responseText; document.all.pdiv.innerHTML=response; } } function handleResponsetwo() { if(reqtwo.readyState == 4){ var response = reqtwo.responseText; document.all.pdivtwo.innerHTML=response; } } function sp() { if (!document.pf.domain.value) { document.all.psuggest.innerHTML="<font size=1>Suggestions for your keyword will appear here.</font>";document.all.pdivtwo.innerHTML="";document.all.pdiv.innerHTML="<font size=1><b>Enter your domain into the box above and results should appear.</b></font>";t=0;return false; } if (ld == document.pf.domain.value) { return false; } if (!nc) { ld = document.pf.domain.value; } nc=0; var iChars = "&#166;!@#$%^&*()+=_[]\\\';,&#163;/{}|\":<>.? "; for (var i = 0; i < document.pf.domain.value.length; i++) { if (iChars.indexOf(document.pf.domain.value.charAt(i)) != -1) { t=0;document.all.psuggest.innerHTML="";document.all.pdivtwo.innerHTML="";document.all.pdiv.innerHTML="<font size=2 color=#FF0000><b>Invalid domain name.<br><br>Letters (a-z), numbers (0-9) and hyphen (-) are allowed only.</b></font>";return false; } } if (!t) { setTimeout('sendRequest(document.pf.domain.value,document.pf.one.value,1);', 900); setTimeout('sendRequest(document.pf.domain.value,document.pf.two.value,2);', 900); t=1; } document.all.pdiv.innerHTML="<table border=0 cellspacing=5 cellpadding=5><tr><td><font size=1 color=#0D73B5><b>Looking for ."+document.pf.one.value+" domain, please wait...</b></font><br><img src=loader.gif /></td></tr></table>"; document.all.pdivtwo.innerHTML="<table border=0 cellspacing=5 cellpadding=5><tr><td><font size=1 color=#0D73B5><b>Looking for ."+document.pf.two.value+" domain, please wait...</b></font><br><img src=loader.gif /></td></tr></table>"; }

    Thanks

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The problem is that your script relies heavily on document.all - which is an IE only way of referencing DOM elements.

    I was surprised that it worked at all in Firefox, until I read this page:
    http://www.mozillazine.org/talkback.html?article=5063
    And indeed, adding the doctype you posted disables this hidden support that Firefox has.

    The solution is to go through the script replacing references of
    document.all.elementId
    with the far more standard
    document.getElementById("elementId")

    For example, you have:
    document.all.psuggest.innerHTML="blah blah";
    that would become:
    document.getElementById("psuggest").innerHTML = "blah blah";

  3. #3
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well doing what you said somewhat fixed that script. The results show, but it doesn't show the loading text and image.

    HTML Code:
    var nc; function addBookmark() { if (window.domaincart && window.sidebar.addPanel) { window.sidebar.addPanel("Domain Check-up","../domains/",''); } else if ( window.external && (navigator.platform=='Win32' || (window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1)) ) { window.external.AddFavorite("../domains/","LevelServe Technologies"); } else if (document.layers) { window.alert('Please click OK then press Ctrl+D to create a bookmark'); } else { window.alert('Please use your browser\'s bookmarking facility to create a bookmark'); } return false; } var t=0; var ld=0; function createXMLHttpRequest() { var ua; if(window.XMLHttpRequest) { try { ua = new XMLHttpRequest(); } catch(e) { ua = false; } } else if(window.ActiveXObject) { try { ua = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { ua = false; } } return ua; } var reqsuggest = createXMLHttpRequest(); var req = createXMLHttpRequest(); var reqtwo = createXMLHttpRequest(); function sendRequest(domain,ext,type) { if (!t) { return false; } domain = domain.replace('&',"%26"); if (type==2) { t = 0; reqsuggest.open('post', '../instant/s.php?domain='+domain); reqsuggest.onreadystatechange = handleResponsesuggestion; reqsuggest.send(null); } if (type == 1) { req.open('get', '../domains/g.php?ext='+ext+'&domain='+domain); req.onreadystatechange = handleResponse; req.send(null); } if (type == 2) { reqtwo.open('get', '../domains/g.php?ext='+ext+'&domain='+domain); reqtwo.onreadystatechange = handleResponsetwo; reqtwo.send(null); } } function handleResponsesuggestion() { if(reqsuggest.readyState == 4){ var response = reqsuggest.responseText; document.getElementById("psuggest").innerHTML=response; } } function handleResponse() { if(req.readyState == 4){ var response = req.responseText; document.getElementById("pdiv").innerHTML=response; } } function handleResponsetwo() { if(reqtwo.readyState == 4){ var response = reqtwo.responseText; document.getElementById("pdivtwo").innerHTML=response; } } function sp() { if (!document.pf.domain.value) { getElementById("psuggest").innerHTML="<font size=1>Suggestions for your keyword will appear here.</font>";getElementById("pdivtwo").innerHTML="";getElementById("pdiv").innerHTML="<font size=1><b>Enter your domain into the box above and results should appear.</b></font>";t=0;return false; } if (ld == document.pf.domain.value) { return false; } if (!nc) { ld = document.pf.domain.value; } nc=0; var iChars = "!@#$%^&*()+=_[]\\\';,/{}|\":<>.? "; for (var i = 0; i < document.pf.domain.value.length; i++) { if (iChars.indexOf(document.pf.domain.value.charAt(i)) != -1) { t=0;getElementById("psuggest").innerHTML="";getElementById("pdivtwo").innerHTML="";getElementById("pdiv").innerHTML="<font size=2 color=#FF0000><b>Invalid domain name.<br><br>Letters (a-z), numbers (0-9) and hyphen (-) are allowed only.</b></font>";return false; } } if (!t) { setTimeout('sendRequest(document.pf.domain.value,document.pf.one.value,1);', 900); setTimeout('sendRequest(document.pf.domain.value,document.pf.two.value,2);', 900); t=1; } getElementById("pdiv").innerHTML="<table border=0 cellspacing=5 cellpadding=5><tr><td><font size=1 color=#0D73B5><b>Looking for ."+document.pf.one.value+" domain, please wait...</b></font><br><img src=../domains/loader.gif /></td></tr></table>"; getElementById("pdivtwo").innerHTML="<table border=0 cellspacing=5 cellpadding=5><tr><td><font size=1 color=#0D73B5><b>Looking for ."+document.pf.two.value+" domain, please wait...</b></font><br><img src=loader.gif /></td></tr></table>"; }


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
  •