topical media & game development

talk show tell print

#javascript-generator-robot-txt.htm / htm



  
  <!-- Paste this code into the CSS section of your HTML document  -->
  
  .table1 {
    border: solid .05em;
    padding: .5em;
  }
  
  <!-- Paste this code into an external JavaScript file named: roboTxt.js  -->
  
  /* This script and many more are available free online at
  The JavaScript Source :: http://javascript.internet.com
  Created by: Lee Underwood :: http://javascript.internet.com/ */
  
  function createRobotTag() {
    var robotsTag="<meta name=\"robots\" content \"";
  
    if (document.getElementById("none").checked) {
      robotsTag += "none\">";
      document.getElementById("index").disabled=true;
      document.getElementById("follow").disabled=true;
    } else if (document.getElementById("none").checked==false) {
      document.getElementById("index").disabled=false;
      document.getElementById("follow").disabled=false;
      if (document.getElementById("index").checked) {
        robotsTag += "noindex, ";
      } else {
        robotsTag += "index, ";
      }
      if(document.getElementById("follow").checked) {
        robotsTag += "nofollow\">";
      } else {
        robotsTag += "follow\">";
      }
    }
    document.getElementById("tag").value = robotsTag;
  }
  
  function googTag() {
    var googleTag="<meta name=\"Googlebot\" content=\"nofollow\">";
    if (document.getElementById("googleBot").checked) {
      document.getElementById("tag2").value = googleTag;
    } else {
      document.getElementById("tag2").value = "";
    }
  }
  
  function copyToClipboard() {
    document.getElementById("tag").focus();
    document.getElementById("tag").select();
    copiedTxt=document.selection.createRange();
    copiedTxt.execCommand("Copy");
  }
  
  function copyToClipboard2() {
    document.getElementById("tag2").focus();
    document.getElementById("tag2").select();
    copiedTxt2=document.selection.createRange();
    copiedTxt2.execCommand("Copy");
  }
  
  <!-- Paste this code into the HEAD section of your HTML document.
       You may need to change the path of the file.  -->
  
  <script type="text/javascript" src="roboTxt.js"></script>
  
  <!-- Paste this code into the BODY section of your HTML document  -->
  
  <table width="60%" align="center" class="table1">
  <tr><td>
  <form>
  <input type="checkbox" id="none" onclick="createRobotTag()"> <strong>Tell robots to ignore this page</strong>
  <br>
  <input type="checkbox" id="index" onclick="createRobotTag()"> <strong>Tell robots to not index this page in the search engines</strong>
  <br>
  <input type="checkbox" id="follow" onclick="createRobotTag()"> <strong>Tell robots to not follow any of the links on this page</strong>
  <p>
  Insert this meta tag in the <head> section of your Web page:<br>
  <input type="text" size="50" id="tag" readonly><br>
  <input type="button" onClick="copyToClipboard()" value="Copy to clipboard"><br><small>[<em>Netscape, Firefox, and Opera users - Press button to select and  [Ctrl]+C to copy</em>]</small>
  <br><br><br>
  <input type="checkbox" id="googleBot" onclick="googTag()"> <strong>Tell only the Googlebot to ignore this page</strong>
  <p>
  Insert this meta tag in the <head> section of your Web page:<br>
  <input type="text" size="50" id="tag2" readonly><br>
  <input type="button" onClick="copyToClipboard2()" value="Copy to clipboard"><br><small>[<em>Netscape, Firefox, and Opera users - Press button to select and [Ctrl]+C to copy</em>]</small>
  </form>
  </td></tr>
  </table>
  <p><div align="center">
  <font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
  by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
  </div><p>
  
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.