Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1095457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:07:40+00:00 2026-05-17T00:07:40+00:00

Your help would be greatly appreciated I have the following code: It is suppose

  • 0

Your help would be greatly appreciated

I have the following code: It is suppose to get the metatags from a website:

function calculate() {
    // This gets the title:
    g_title = ('' + document.title + '');
    g_title_count = ('' + document.title.split(' ').length + '');
    g_title_length = ('' + document.title.length + '')
    // This checks all the MetaTags:
    g_metadata = document.getElementsByTagName("meta")[i];
    g_keywords = "test";
    if (typeof g_metadata != 'undefined') {
        if (g_metadata) {
            var i = 0;
            for (i = 0; i <= 10; i++) {
                if (g_metadata.name == 'keywords') {
                    g_keywords[i] = (g_metadata.name[i] + g_metadata.content[i]);
                }
            }
        }
    }
}

This value currently returns “test” as specified in the code above:

document.form1.g_keywords.value = g_keywords

However I need it to capture the keywords metatag, description and title.

<title>Test 1</title>
<meta name="keywords"content="test2" />
<meta name="description" content="test3" />

and then write it to a form:

<textarea name="g_keywords" id="g_keywords" cols="80" rows="5" onchange="calculate(this.form1)"></textarea>

It currently works for the Title but not to get the <meta name="keywords" content="" > tag

if (g_metadata.name == 'keywords') {
    g_keywords[i] = (g_metadata.name[i] + g_metadata.content[i]);
}

I have tried it by creating the above but are not sure how to execute it…

Please help – Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:07:41+00:00Added an answer on May 17, 2026 at 12:07 am
    // Collect all keywords
    g_metadata = document.getElementsByTagName("meta");
    g_keywords = []; // should be an array
    var len = g_metadata.length;
    for (var i = 0; i < len; i++) {
        if (g_metadata[i].name == 'keywords') {
            g_keywords = g_metadata[i].content.split(",");
        }
    }​
    

    I think there supposed to be only one keyword <meta> tag, and all the keywords are listed there separated by comma.
    [Demo]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to regular expressions and would appreciate your help. I'm trying to put
I need your help, For example I have a decimal type variable and I
I've some questions .. and I really need your help. I have an application.
I've following problem, which I've not been able to do successfully. Your help will
thanks in advance for your help. I'm working on this site and have an
I really need your help in my issue very quickly and it's too close
thanks in advance for your help. I am wondering if there is a (design)
I need your help to define a special case in XML schema: A sequence
Does the functional spec help or hinder your expectations? Do programmers who practice the
Is there a free software for creating windows help files for your program? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.