Reputation: 357
Is there code to fetch the meta data information of other websites such as title,keyword using javascript ? document.getElementById will help to fetch the information of current document.Likewise is there a code to fetch information of other than current document.
Upvotes: 0
Views: 468
Reputation: 1038720
Sure, you could use the getElementsByTagName
method to extract this information from the current document:
alert(document.getElementsByTagName('title')[0].innerHTML);
As far as other web sites are concerned, well, as you know the same origin policy restriction prevents you from retrieving their contents using AJAX. But if you have a server side script on your domain that will retrieve the HTML contents of those remote sites you could perfectly fine send an AJAX request to your script and in the success callback parse the HTML and retrieve the information you are interested in (meta, title, ...). But since you've already setup a server side script to retrieve the remote contents it could directly be this server side script that parses the remote HTML and returns you the required information.
Upvotes: 2