Getting this to work in Firefox?

SpaceshipSpaceship
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.
Unstoppable Domains — AI StorefrontUnstoppable Domains — AI Storefront
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 TransferDynadot — .com Transfer
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomainEasy — Live Options
DomDB
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back