/    Sign up×
Community /Pin to ProfileBookmark

Reading meta data of another page

Hello,
I know how to read the meta data from the page that is currently opened, but can you read the meta data of another page without opening it?

What I am trying to accomplish is to determine (by the meta tags) if the page is one I want to user to see. If not, I can then re-direct them to another site without them knowing it.

Thanks in advance.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Aug 10.2005 — If the site is on the same domain then you can do it with JavaScript. If it is on another domain then JavaScript is not your answer.

Eric
Copy linkTweet thisAlerts:
@lewyauthorAug 10.2005 — Let's pretend that we are in the same domain, can you show how this can be done?

Thanks.
Copy linkTweet thisAlerts:
@A1ien51Aug 10.2005 — lets pretend, sounds like you are hoping you could get it to work with other domains and it is not going to happen.

Any Ajax request can allow you to get the html when you use the responseText.

Eric
Copy linkTweet thisAlerts:
@lewyauthorAug 11.2005 — Let me say this in another way. I know that if I can find out how to read another file before opening it, I can put this solution into the same domain. Right now it's not.

I just thought that if I could find a simple script example, I could modify (the script below) that reads the meta data in the same page.

function getKeywords ()

{

var metaElements = document.all ?

document.all.tags('META') :

document.getElementsByTagName ?

document.getElementsByTagName ('META') : new Array();

var metaKeywords = new Array();

var i = 0;

for (var m = 0; m < metaElements.length; m++)

if (metaElements[m].name == 'keywords')

metaKeywords[i++] = metaElements[m].content;

return metaKeywords;}


BTW - please excuse my ignorance, but what is Ajax?

Thanks.
Copy linkTweet thisAlerts:
@A1ien51Aug 11.2005 — I just wrote this real quick without testing so hopefully you get the basic idea:

<i>
</i>&lt;HTML&gt;
&lt;HEAD&gt;
&lt;title&gt;testAj&lt;/title&gt;
&lt;script type="text/javascript"&gt;

<i> </i> var reqXML;

<i> </i> function LoadXMLDoc(url){

<i> </i> if (window.XMLHttpRequest){
<i> </i> reqXML = new XMLHttpRequest();
<i> </i> }
<i> </i> else if(window.ActiveXObject){
<i> </i> reqXML = new ActiveXObject("Microsoft.XMLHTTP");
<i> </i> }

<i> </i> if(reqXML){
<i> </i> reqXML.open("POST", url, true);
<i> </i> reqXML.onreadystatechange = BuildXMLResults;
<i> </i> reqXML.send(null);
<i> </i> }
<i> </i> else{
<i> </i> alert("Your browser does not support Ajax");
<i> </i> }

<i> </i> }

<i> </i> function BuildXMLResults(){
<i> </i> if(reqXML.readyState == 4){
<i> </i> if(reqXML.status == 200){

<i> </i> var strText = reqXML.responseText;
<i> </i> document.getElementById("spanOut").innerHTML = strText;

<i> </i> }
<i> </i> else{

<i> </i> alert("There was a problem retrieving the XML data:n" + reqXML.statusText);

<i> </i> }
<i> </i> }
<i> </i> }
<i> </i> window.onload function(){
<i> </i> LoadXMLDoc("yourPage.html");
<i> </i> }
<i> </i>&lt;/script&gt;
&lt;/HEAD&gt;
&lt;body&gt;
&lt;span id="spanOut"&gt;&lt;/span&gt;
&lt;/body&gt;
&lt;/HTML&gt;


Eric
×

Success!

Help @lewy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...