SitePoint Sponsor

User Tag List

Results 1 to 24 of 24
  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 : LevelServe</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">LevelServe  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 LevelServe 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="http://192.168.0.1/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%" 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 = "!@#$%^&*()+=_[]\\\';,/{}|\":<>.? "; 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 cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try the following.
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    	<meta name="author" content="John Smith" />
    	<meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />

  3. #3
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That still doesn't work in firefox but IE is still working. The firefox console spits this "document.all has no properties".

  4. #4
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #5
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After reading that blog, I changed all document.all to document.getElementById and I still have the same problem.

  6. #6
    SitePoint Evangelist
    Join Date
    Mar 2006
    Location
    Sweden
    Posts
    451
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is the Firefox console still saying "document.all has no properties" after you changed every document.all to document.getElementById?

  7. #7
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you typing it as:
    HTML Code:
    document.getElementById.pdiv.innerHTML
    or are you using the syntax:
    HTML Code:
    document.getElementById("pdiv").innerHTML
    The parenthesis are needed because getElementById is actually a document method, not a property, so you have to pass the id in order to retrieve and manipulate the element.

  8. #8
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jtrelfa View Post
    Are you typing it as:
    HTML Code:
    document.getElementById.pdiv.innerHTML
    or are you using the syntax:
    HTML Code:
    document.getElementById("pdiv").innerHTML
    The parenthesis are needed because getElementById is actually a document method, not a property, so you have to pass the id in order to retrieve and manipulate the element.
    Yes. I went through and changed all the document.all's to document.getElementById("value"). That made the script function in firefox, but my loading text and image will not work now.

    What is stopping the loading text and image to fail?
    Last edited by LevelServe; Dec 8, 2006 at 18:19.

  9. #9
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm going to let the other thread die.

    I don't see any loading text or image in your html - can you post a link to the site so we can see what's going on?

  10. #10
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jimfraser View Post
    I'm going to let the other thread die.

    I don't see any loading text or image in your html - can you post a link to the site so we can see what's going on?
    Yea. I contacted a mod to merge them yesterday, but it wasn't. As for the loading image, it is at the end of the js file.

    Thanks

  11. #11
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Notice that the src attribute of the image at the end doesn't show up in quotes.

    Try
    Code:
    <img src=\"loader.gif\" />
    instead.

    You should do the same for all of the other attributes (the backward slashes escape the " inside the expression).

  12. #12
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That didn't solve the problem.

    Code:
     var nc; function addBookmark() { if (window.domaincart && window.sidebar.addPanel) { window.sidebar.addPanel(" Instant Domain Check","./",''); } else if ( window.external && (navigator.platform=='Win32' || (window.ScriptEngine && ScriptEngine().indexOf('InScript') + 1)) ) { window.external.AddFavorite("/","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('&',"&#37;26"); if (type==2) { t = 0; reqsuggest.open('get', 's.php?domain='+domain); reqsuggest.onreadystatechange = handleResponsesuggestion; reqsuggest.send(null); } if (type == 1) { req.open('get', 'g.php?ext='+ext+'&domain='+domain); req.onreadystatechange = handleResponse; req.send(null); } if (type == 2) { reqtwo.open('get', '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>"; }

  13. #13
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It sure would be easier to read your script if it wasn't all on one line...

    Dave

  14. #14
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dwees View Post
    It sure would be easier to read your script if it wasn't all on one line...

    Dave
    It didn't write it and Im also not a JS coder. PHP and shell scripting are my specialties.

    Thanks

  15. #15
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright.. I really need help so I will up the offer to a steak dinner worth $30.

    I really need this to work!

  16. #16
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you provide a link to the page?

  17. #17
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Easier to read

    This is what I meant by easier to read.

    Code:
    var nc; 
    
    function addBookmark() { 
    	if (window.domaincart && window.sidebar.addPanel) { 
    		window.sidebar.addPanel(" Instant Domain Check","./",''); 
    	} else if ( window.external && (navigator.platform=='Win32' || (window.ScriptEngine && 
    
    ScriptEngine().indexOf('InScript') + 1)) ) { 
    		window.external.AddFavorite("/","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('get', 's.php?domain='+domain); 
    		reqsuggest.onreadystatechange = handleResponsesuggestion; 
    		reqsuggest.send(null); 
    	} 
    	if (type == 1) { 
    		req.open('get', 'g.php?ext='+ext+'&domain='+domain); 
    		req.onreadystatechange = handleResponse; req.send(null); 
    	} 
    	if (type == 2) {
    		reqtwo.open('get', '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 = "!@#$%^&*()+=_[]\\\';,/{}|\":<>.? "; 
    	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>"; 
    }
    One thing I do notice is that the document.all's have snuck back in. Instead of document.all.pdivtwo, use document.getElementById("pdivtwo").

    I'll take a look at this later today in more detail and see if I can't get it to work.

  18. #18
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dwees View Post
    This is what I meant by easier to read.

    One thing I do notice is that the document.all's have snuck back in. Instead of document.all.pdivtwo, use document.getElementById("pdivtwo").

    I'll take a look at this later today in more detail and see if I can't get it to work.
    Actually I realized that the one I put up was the old one. Here is the current js file I am working with.

    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('&',"&#37;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 = "&#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;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=\"../domains/loader.gif\" /></td></tr></table>"; }

  19. #19
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    First thing first..

    While it's a good practice to minify your code, you should maintain an un-minified version for troubleshooting. This will help you debug when FF/IE spits out an "error on line xx" code. I've expanded your code here. I recommend you use this until everything is resolved:
    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=\"../domains/loader.gif\" /></td></tr></table>"; 
    }
    The first thing that jumped out at me is the use of "getElementById()" - you need to prefix those commands with "document.":

    document.getElementById("div");

    That was the first thing that FF choked on. These all show up in "function sp", so I'd fix that first thing. You can re-write that as follows:
    Code:
    function sp() { 
    	if (!document.pf.domain.value) { 
    		document.getElementById("psuggest").innerHTML="<font size=\"1\">Suggestions for your keyword will appear here.</font>";
    		document.getElementById("pdivtwo").innerHTML="";
    		document.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;
    			document.getElementById("psuggest").innerHTML="";
    			document.getElementById("pdivtwo").innerHTML="";
    			document.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; 
    	} 
    	document.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>"; 
    	document.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=\"../domains/loader.gif\" /></td></tr></table>"; 
    }
    When I ran a preliminary test - locally on my machine - the text showed up in the boxes "Looking for .com domain, please wait..." and "Looking for .net domain, please wait...", so I assume that's part of what you're looking for. Also, both XHR requests fired off - one a POST and the other a GET - but I got a 404 (since I don't have those files, etc).

    Try this new code out and see if it helps.

    Jon

  20. #20
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    document.getElementById();

    Another suggestion, if you end up doing a lot of Javascript coding, is to create a function to handle the document.getElementById. For example, since I'm not interested in supporting IE4, I use:

    Code:
    function $e(el) {
           return document.getElementById(el);
    }
    and when I want to get an element by Id I use the syntax $e("pdiv2");
    I use $e instead of the more populer $ to prevent naming conflicts with the jQuery library, which I've started using recently.

    Another option is to modify the function to something like (no testing done, since I don't actually a version of IE4 to test with...):

    Code:
    function $e(el) {
           if (document.all) {
                 return document.all.el;
           } else {
                 return document.getElementById(el);
           }
    }
    which should return the proper object independent of the users browser. However it should be noted that proper Ajax support doesn't exist in IE 4, and you have to resort to hidden (i)frame trickery.

    I believe how this works is that you use Javascript to change the source of a very small (i)frame with a hidden visibility, and you have the server side script produce HTML with the text you want present in an textarea inside the hidden frame, and then you can read the text from the textarea if you know its ID.

    Dave

  21. #21
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where's the free lunch?

  22. #22
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have not been able to test your code yet, but if it works then I will be very pleased. I can assure you that you will get your free lunch.

    Thanks

  23. #23
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It worked jtrelfa.. Sending Pm.. Many thanks

  24. #24
    SitePoint Enthusiast LevelServe's Avatar
    Join Date
    Nov 2006
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the PM I just got from J. What a nice thing to do!

    I have paypal - email@removed - but you don't have to actually pay me anything. I like helping people out. Consider it a Christmas present if you like.

    And my response.
    What a nice gesture! Merry Christmas to you too.

    Do you need any hosting? How about a free year.
    We got shared, reseller, and multi-site plans. Tell me what you need and its done.


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
  •