NameSilo

Getting this to work in Firefox?

Spaceship Spaceship
Watch

PoorDoggie

Soon to be RICHdoggie!VIP Member
Impact
18
Code:
<script language="javascript">
    function checkform(form){
      if(form["q"].value == ""){
       alert("Please insert keyword(s) to search for");
        form["q"].focus();
        return false ;
      }
      return true;
    }
    function toProperCase(astring){
      return astring.toLowerCase().replace(/\w+/g,function(s){return s.charAt(0).toUpperCase() + s.substr(1);})
    }
    function changemode(newmode){
      document.all.m.value=newmode.toLowerCase();
      document.all.sixBtn.value=toProperCase(newmode)+' Search';
      document.all.web.className="standardmode";
      document.all.Local.className="standardmode";
      document.all.Images.className="standardmode";
      document.all.News.className="standardmode";
      document.all.Video.className="standardmode";
      document.all.Domains.className="standardmode";
      document.getElementById(newmode).className="newmode";
      if(newmode == "Local"){
        document.all.q.style.width="192px";
        document.getElementById("localSearchBar").innerHTML="ย <input name=\"location\" id=\"location\" size=\"27\" value=\"Location (eg: NY or Zip Code)\" onFocus=\"if(this.value=='Location (eg: NY or Zip Code)'){this.select();}\" />";
      }
      else{
        document.all.q.style.width="384px";
        document.getElementById("localSearchBar").innerHTML="";
      }
    }
  </script>
I know that firefox uses different versions of Javascript, but:
a) what do I need to do to this code to make it compatible with firefox?
b) how would I integrate it so that it chooses the right code for the right browser
c) are there any other browsers that I need to code it for?

Thanks a lot
Tom
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
no-one know?
 
0
•••
I've looked it over a few times and i'm not really sure what you want to do but I think all the functions you have are compatible with Firefox as far as I know.
 
0
•••
I agree with Noobie. Is there something that isn't preforming the way it should? Or are you just assumming it won't work as is?
 
0
•••
if you have firefox, go into it: http://www.beta.6yd.net/beta_search/ the links don't work.

here is the code where the links are:
Code:
<div onClick="changemode('web')" class="newmode" id="web">Web</div>
                  ย |ย 
                  <div onClick="changemode('Local')" class="standardmode" id="Local">Local</div>
                  ย |ย 
                  <div onClick="changemode('Images')" class="standardmode" id="Images">Images</div>
                  ย |ย 
                  <div onClick="changemode('News')" class="standardmode" id="News">News</div>
                  ย |ย 
                  <div onClick="changemode('Video')" class="standardmode" id="Video">Video</div>
                  ย |ย 
                  <div onClick="changemode('Domains')" class="standardmode" id="Domains">Domains</div>
                  ย |ย 
                  <div onClick="location.href='more'" class="standardmode" id="more">More ยป</div>
 
0
•••
I did a little research and well the problem is your use of document.all in your changeMode function which isn't supported by mozilla (I think few browser do). You need to use the document.getElementById() which is the W3C standard for grabbing elements and so is supported even in IE.

Code:
<script language="javascript">
    function checkform(form){
      if(form["q"].value == ""){
       alert("Please insert keyword(s) to search for");
        form["q"].focus();
        return false ;
      }
      return true;
    }
    function toProperCase(astring){
      return astring.toLowerCase().replace(/\w+/g,function(s){return s.charAt(0).toUpperCase() + s.substr(1);})
    }
    function changemode(newmode){
      document.getElementById("m").value=newmode.toLowerCase();
      document.getElementById("sixBtn").value=toProperCase(newmode)+' Search';
      document.getElementById("web").className="standardmode";
      document.getElementById("Local").className="standardmode";
      document.getElementById("Images").className="standardmode";
      document.getElementById("News").className="standardmode";
      document.getElementById("Video").className="standardmode";
      document.getElementById("Domains").className="standardmode";
      document.getElementById(newmode).className="newmode";
      if(newmode == "Local"){
        document.getElementById("q").style.width="192px";
        document.getElementById("localSearchBar").innerHTML="ย <input name=\"location\" id=\"location\" size=\"27\" value=\"Location (eg: NY or Zip Code)\" onFocus=\"if(this.value=='Location (eg: NY or Zip Code)'){this.select();}\" />";
      }
      else{
        document.getElementById("q").style.width="384px";
        document.getElementById("localSearchBar").innerHTML="";
      }
    }
</script>

Also you will have to give the sixBtn an ID for it to work.
 
0
•••
That works perfectly. Thanks a lot! :)
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back