Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Creating an advance Meta tag generator using Java Script.

Author: DevASP
Download Source Code : 589_MetaTagGenarater.zip

This article is about how you can create an application which will take the attribute values and generate Meta tag from those values for you. It's fast and an easy way to create all kinds of META tags

 

 

Steps you will do.

 

Start visual studio and create a new web application.

 

Open the HTML design of your web form and add the following JavaScript tag and function before closing the head tag.

 

 

<SCRIPT LANGUAGE="JavaScript">

function create(form) {

  if (confirm("Are you sure?")) {

    form.story.value = "Advanced Meta Tag Generator \n" +

   "author: Daniel Toljaga (http://www.bosniak.com) \n" +

   "Instructions: Simply copy the following lines of code and insert them " +

      "between the <HEAD> and </HEAD> tags in your HTML document. That's it! \n\n";

    if (form.input1.value != "") {

      form.story.value +="<META NAME=\"Title\" CONTENT=\"" +

      form.input1.value + "\">\n";

    }

    if (form.input2.value != "") {

      form.story.value +="<META NAME=\"Author\" CONTENT=\"" +

      form.input2.value + "\">\n";

    }

    if (form.input3.value != "") {

      form.story.value +="<META NAME=\"Subject\" CONTENT=\"" +

      form.input3.value + "\">\n";

    }

    if (form.input4.value != "") {

      form.story.value +="<META NAME=\"Description\" CONTENT=\"" +

      form.input4.value + "\">\n";

    }

    if (form.input5.value != "") {

      form.story.value +="<META NAME=\"Keywords\" CONTENT=\"" +

      form.input5.value + "\">\n";

    }

    if (form.input6.value != "") {

      form.story.value +="<META NAME=\"Generator\" CONTENT=\"" +

      form.input6.value + "\">\n";

    }

    if (form.input7.value != "") {

      form.story.value +="<META NAME=\"Language\" CONTENT=\"" +

      form.input7.value + "\">\n";

    }

    if (form.input8.value != "") {

      form.story.value +="<META NAME=\"Expires\" CONTENT=\"" +

      form.input8.value + "\">\n";

    }

    if (form.input9.value != "") {

      form.story.value +="<META NAME=\"Abstract\" CONTENT=\"" +

      form.input9.value + "\">\n";

    }

    if (form.input10.value != "") {

      form.story.value +="<META NAME=\"Copyright\" CONTENT=\"© " +

      form.input10.value + "\">\n";

    }

    if (form.input11.value != "") {

      form.story.value +="<META NAME=\"Designer\" CONTENT=\"" +

      form.input11.value + "\">\n";

    }

    if (form.input12.value != "") {

      form.story.value +="<META NAME=\"Publisher\" CONTENT=\"" +

      form.input12.value + "\">\n";

    }

    if (form.input13.value != "") {

      form.story.value +="<META NAME=\"Revisit-After\" CONTENT=\"" +

      form.input13.value + " \Days\">\n";

    }

    if (form.input14.value != "") {

      form.story.value +="<META NAME=\"Distribution\" CONTENT=\"" +

      form.input14.options[form.input14.selectedIndex].value + "\">\n";

    }

    if (form.input15.value != "") {

      form.story.value +="<META NAME=\"Robots\" CONTENT=\"" +

      form.input15.options[form.input15.selectedIndex].value + "\">\n";

    }

  }

}

 

</script>

 

  

now add the following HTML code which will design the layout of your web form and call the above JavaScript function to generate meta tag.

 

<body>

 

<div align="center">

  <center>

    <p align="left"> </p>

    <table class=normal  WIDTH="600" BORDER="0" CELLSPACING="0" CELLPADDING="0">

  <tr>

    <td><center><font face="verdana" size="4">Advanced META Tag Generator</font></center>

    <form>

      <div align="center"><center><table class=normal  BORDER="0" CELLPADDING="2">

        <tr>

          <td>Title:</td>

          <td><input TYPE="text" NAME="input1" SIZE="40"></td>

        </tr>       

        <tr>

          <td>Author:</td>

          <td><input TYPE="text" NAME="input2" SIZE="40"></td>

        </tr>

        <tr>

          <td>Subject:</td>

          <td><input TYPE="text" NAME="input3" SIZE="40"></td>

        </tr>

        <tr>

          <td>Description:</td>

          <td><input TYPE="text" NAME="input4" SIZE="40"></td>

        </tr>

        <tr>

          <td>Keywords:</td>

          <td><input TYPE="text" NAME="input5" SIZE="40"></td>

        </tr>

        <tr>

          <td>Generator:</td>

          <td><input TYPE="text" NAME="input6" SIZE="40"></td>

        </tr>

        <tr>

          <td>Language:</td>

          <td><input TYPE="text" NAME="input7" SIZE="40"></td>

        </tr>        

        <tr>

          <td>Expires:</td>

          <td><input TYPE="text" NAME="input8" SIZE="40"></td>

        </tr>       

        <tr>

          <td>Abstract:</td>

          <td><input TYPE="text" NAME="input9" SIZE="40"></td>

        </tr>      

        <tr>

          <td>Copyright:</td>

          <td><input TYPE="text" NAME="input10" SIZE="40"></td>

        </tr>      

        <tr>

          <td>Designer:</td>

          <td><input TYPE="text" NAME="input11" SIZE="40"></td>

        </tr>      

        <tr>

          <td>Publisher:</td>

          <td><input TYPE="text" NAME="input12" SIZE="40"></td>

        </tr>       

        <tr>

          <td>Revisit-After:</td>

          <td><input TYPE="text" NAME="input13" SIZE="40"></td>

        </tr>    

        <tr>

          <td>Distribution:</td>

          <td><select NAME="input14" size="1">

             <option VALUE="" SELECTED>Select One</option>

            <option VALUE="Global">1. Global</option>

            <option VALUE="Local">2. Local</option>

            <option VALUE="IU">3. Intern Use</option>

          </select></td>

        <tr>

          <td>Robots:</td>

          <td><select NAME="input15" size="1">

            <option VALUE="" SELECTED>Select One</option>

            <option VALUE="All">1. All</option>

            <option VALUE="None">2. None</option>

            <option VALUE="Index">3. Index</option>

            <option VALUE="No Index">4. No Index</option>

            <option VALUE="Follow">5. Follow</option>

            <option VALUE="No Follow">6. No Follow</option>

          </select></td>

        </tr>

        </tr>

      </table>

      </center></div><blockquote>

        <p><input TYPE="button" VALUE="Create META tags" ONCLICK="create(this.form)"> <input

        TYPE="reset" VALUE="Clear All"> <textarea WRAP NAME="story" ROWS="12" COLS="65"></textarea>

        </p>

      </blockquote>

    </form>

    </td>

  </tr>

</table>

  </center>

</div>

 

 

<p><center>

<font face="arial, helvetica" size"-2">Dont forget to visit Devasp<br>

by <a href="http://www.devasp.com">www.devasp.com</a></font>

</center><p>

 

  </body>

 

Run your application and enter the values for meta tag attributes click the button, it will generate the meta tag for you.

 

 

 

 

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< How we can create Slide show of images in Window Form.

Disclaimer - Privacy
© 2002-2017 DevASP.net