To check for Meta Tags values in JavaScript:
1.Open your text editor and make a new file and name it "metaTags.html." Add HTML tags in your file.
<html>
<head></head>
<body></body>
</html>
2.Add meta tags in the file between "<head>" and "</head>". Name the first meta tag meta1 , second meta2 and third meta3 using the name property <html>.
<head>
<title></title>
<meta name="meta1">
<meta name="meta2">
<meta name="meta3">
</head>
<body></body>
</html>
3.Assign content values to the meta tags. <html>. Also add a Javascript script tag between <body> </body> tags.
<head>
<title></title>
<meta name="meta1" content="firstval">
<meta name="meta2" content="secval">
<meta name="meta3" content="thirdval">
</head>
<body>
<script type="text/javascript">
</script>
</body>
</html>
4. Set your script's type value as text/javascript and then add </script>."
<body>
<script type="text/javascript">
</script>
</body>
5.Use the Javascript method getElementsByTagName() to retrieve your meta tag values.
<body>
<script type="text/javascript">
var mTags = document.getElementsByTagName('meta');
</script>
</body>
6 to determine the meta tag count use the Javascript length method
<body>
<script type="text/javascript">
var metaTags = document.getElementsByTagName('meta');
var metaTagLength=metaTags.length;
</script>
</body>
7.Using the metatagLength you can create a Javascript loop to loop the meta tag values.
<body>
<script type="text/javascript">
var metaTags = document.getElementsByTagName('meta');
var metaTagLength=metaTags.length;
for(var i=0;i<metaTagLength;i++)
{
}
</script>
</body>
8.to write the meta tag contents to the page use document.write
<body>
<script type="text/javascript">
var metaTags = document.getElementsByTagName('meta');
var metaTagLength=metaTags.length;
for(var i=0;i<metaTagLength;i++)
{
document.write(metaTags[i].content);
}
</script>
</body>
9 .Open metaTags.html in a browser. Check that each meta tag value is written to the page.
Checking for Meta Tag Values in JavaScript
To check for Meta Tags values in JavaScript:1.Open your text editor and make a new file and name it...
javascript meta tag values
Also tagged with one or more of these keywords: javascript, meta tag values
Web Design →
Javascript →
Comparing Strings in JavaScriptStarted by Salwa, 18 Jul 2013 comparing strings, javascript |
|
|
||
Web Design →
Javascript →
Using OnSubmit in JavaScriptStarted by Salwa, 18 Jul 2013 javascript, onsubmit event |
|
|
||
Web Design →
Javascript →
Downloading Javascript to iPodStarted by OneDes, 13 Jun 2013 downloading, javascript, to ipod |
|
|
||
Web Design →
Javascript →
Downloading JavaScript to BlackBerryStarted by OneDes, 13 Jun 2013 downloading, javascript and 1 more... |
|
|
||
Web Design →
Javascript →
Enabling JavaScript on a MacStarted by OneDes, 13 Jun 2013 enable, javascript, mac |
|
|
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users