Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Can you write a meta tag after a page is loaded?

    Goal - to generate a keyword meta tag based on text from a page.
    Plan - to use a span tag with a class of keyword to wrap a word or phrase to be used in the keyword meta tag.

    Planned Steps:
    1. find all span tags
    2. loop thru span tags to find the ones with a class of "keyword"
    3. get the text between the open and closing keyword span tags
    4. write a keyword meta tag to the head element with the text gathered.

    Issue - Since the page needs to be loaded for the script to find the span tags, is it possible to write the meta tag after it's loaded? Would I need to reload the page to write it in? Or, is this better handled by PHP?

    Thanks in advance for any help,
    Mike

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    What would be the point? Using javascript will make the meta tag useless to search engines. Doing it server side would be better but a little time consuming because you would need to get the contents of the page, search it, and add the meta tag before it gets to the user.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    Regular Coder
    Join Date
    May 2007
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Generate a keywords meta tag using JS doesn't make a sense, because robots like Googlebot ignore JS. PHP (or server side scripting) is the only way.
    Last edited by smalldog; 05-16-2007 at 04:40 PM.
    Forum for webmasters and developers
    http://www.htmlfrenzy.com
    Are you an IT expert? Join our Reward system
    www.htmlfrenzy.com/reward-system.php

  • #4
    New Coder
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You're both absolutely right, I didn't think of that. Question answered.

    They really need a smiley that conveys blonde moment.

    Thanks guys.

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Most search engines completely ignore the keywords meta tag in any case.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •