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 1092151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:38:22+00:00 2026-05-16T23:38:22+00:00

I am trying to capture html <title></title> and Metadata from with in a form1

  • 0

I am trying to capture html

<title></title>

and Metadata from with in a form1 but not exactly sure how to do it…

My quess is to do it like: document.write(document.form1.title); or document.write.texteara.(document.form1.title);
but this is not working for me…

  <textarea name="textarea" id="textarea" cols="45" rows="5"><title>This is the title tag extracted</title><meta name="keywords" content="test 1, test 2, test3" /></textarea>
  </label>
</form>
<script type="text/javascript" src="<%= g_page_site_actual %>/js/jquery-1.4.2.min.js"></script>
<script language="JavaScript"><!--
if (document.getElementsByName) {
  var metaArray = document.getElementsByName('Author');
  for (var i=0; i<metaArray.length; i++) {
    document.write(metaArray[i].content + '<br>');
  }

  var metaArray = document.getElementsByName('Description');
  for (var i=0; i<metaArray.length; i++) {
    document.write(metaArray[i].content + '<br>');
  }

  var metaArray = document.getElementsByName('Keywords');
  for (var i=0; i<metaArray.length; i++) {
    document.write(metaArray[i].content + '<br>');
  }
}
document.write(document.form1.title);
//--></script>

Any ideas how I can capture the metadata from within a textarea?

  • 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-16T23:38:23+00:00Added an answer on May 16, 2026 at 11:38 pm

    A textarea contains a simple string of text. There are no elements or metadata.

    <textarea name="textarea" id="textarea" cols="45" rows="5"><title>This is the title tag extracted</title><meta name="keywords" content="test 1, test 2, test3" /></textarea>
    

    This is invalid, though browsers typically fix it up for you (until the sequence </textarea, anyway). You must HTML-encode < and & in the content of a <textarea> just like all text content and attribute values:

    <textarea name="textarea" id="textarea" cols="45" rows="5">&lt;title>This is the title tag extracted&lt;/title>&lt;meta name="keywords" content="test 1, test 2, test3" /></textarea>
    

    You’d then read the contents of the textarea with input.value as with any other field.

    If you want to parse that string value into an HTML document and extract parts of it, you’ll need to write it to an element using element.innerHTML= value and then use DOM methods to extract data from the element:

    var el= document.createElement('head');
    el.innerHTML= document.getElementById('textarea').value;
    alert(el.getElementsByTagName('title')[0].firstChild.value);
    alert(el.getElementsByTagName('meta')[0].content);
    

    Unfortunately IE can’t do this because it can’t set innerHTML on <head> or many other elements that aren’t normal block/inline elements. To get it to work on IE, you’d have to use a complete new document for the content to go into (what a pain):

    <iframe id="iframe"></iframe>
    <script type="text/javascript">
        var iframe= document.getElementById('iframe');
        var idoc= 'contentDocument' in iframe? iframe.contentDocument : iframe.contentWindow.document;
        idoc.write(document.getElementById('textarea').value);
        idoc.close();
        alert(idoc.title);
        alert(idoc.getElementsByTagName('meta')[0].content);
    </script>
    

    It seems to me very unlikely that this is a good idea. Can’t you have the server-side generate a page that passes information that JavaScript needs to use in a manner more convenient to JavaScript? eg. spit out a JSON-encoded lookup like:

    <script type="text/javascript">
        var info= {
            "title": "This is the title tag extracted",
            "keywords": ["test 1", "test 2", "test3"]
        };
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to capture output from an install script (that uses scp) and
I am trying to capture sub-strings from a string that looks similar to 'some
I have an application in which I'm trying to capture the shift key modifier
I'm trying to do an image capture on a high end Nokia phone (N95).
Trying to get my css / C# functions to look like this: body {
I'm trying to figure out how to capture a fully rendered page and manipulate
Here is what I'm trying to do, Capture my form submission post it to
I'm trying to capture the mousewheel event on a Silverlight 4 DataGrid. The problem
I am trying to capture the SelectedIndexChanged event for a drop down list I
I am trying to capture a key press on the return key. How do

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.