i am using this code to alert all meta tag in the page. for e.g. http://shodhganga.inflibnet.ac.in/handle/10603/2769 in this many meta array are used i want to extract all the meta tag on another page.please help me . thanks in advance
window.onload = function(){
var metaData = document.getElementsByTagName('meta')
for(var i=0;i<metaData.length;i++)
{
alert(metaData[i].name);
alert(metaData[i].content);
// talk to your db here for individual entries of meta using name and content
// properties
}
}
You're trying to access the meta tags in a remote page. You'll want to use PHP for that, since Javascript won't be able to access the details in that page.
Luckily, there's get_meta_tags
function. You can do something like:
$url = 'http://shodhganga.inflibnet.ac.in/handle/10603/2769';
$tags = get_meta_tags($url);
print_r($tags);
Example:
echo $tags['generator'].'<br>';
echo $tags['dcterms_spatial'].'<br>';
echo $tags['dc_creator'];
Output:
DSpace 1.8.2
Physical education
Balasubramanian, K
And then, you can pass the values to Javascript and use it however you like.
Hope this helps!