By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,498 Members | 1,558 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,498 IT Pros & Developers. It's quick & easy.

Getting data off another webpage

P: 2
Hi, I'm trying to get data off another web page within the javascript on my page. For instance, I have the URL of some webpage and I want to look at the page and get out a specific element, say a property or a specific tag on that page. I want to be able to go through that page's content. Does anybody know a good way to do this? I have tried using an XMLHttpRequest object but I get a NS_ERROR_XPC_JS_THREW_STRING.

Thanks.
Jul 24 '08 #1
Share this Question
Share on Google+
4 Replies


gits
Expert Mod 5K+
P: 5,320
when the page is from another domain you cannot use javascript to retrieve/modify anything there ... it would be considered as a cross-domain-scripting-security issue ... have a look here

kind regards
Jul 24 '08 #2

P: 2
when the page is from another domain you cannot use javascript to retrieve/modify anything there ... it would be considered as a cross-domain-scripting-security issue ... have a look here

kind regards
I don't think what I'm trying to do is that complex that it wouldn't be allowed due to cross-domain checks. All I want to do is see what's on the other page. I don't want to modify it or anything like that, all I want to be able to do is see it. All I need is that page in some kind of object that I can read from (but not write to). Basically I want to get the document from that page and use it as a read-only object. Even if I could just store the source code as a string that would work fine. I don't see why I can navigate to that page and hit 'view source' but I can't view that source from within javascript code.
Jul 24 '08 #3

rnd me
Expert 100+
P: 427
I don't think what I'm trying to do is that complex that it wouldn't be allowed due to cross-domain checks. All I want to do is see what's on the other page. I don't want to modify it or anything like that, all I want to be able to do is see it. All I need is that page in some kind of object that I can read from (but not write to). Basically I want to get the document from that page and use it as a read-only object. Even if I could just store the source code as a string that would work fine. I don't see why I can navigate to that page and hit 'view source' but I can't view that source from within javascript code.
you already got the answer, even if you didn't want to hear it. the browser doesn''t care about your intentions, or that you are an all-around nice guy. without rules, society would break down.

the browser can blame YOU for clicking view source on the other page, you are the responsible party. on a script, there is not accountability, only prevention.
Jul 24 '08 #4

gits
Expert Mod 5K+
P: 5,320
have you had a look at the provided link? ... its is as it is ... even when you just want to read the page ... to get it to work you need a kind of serverside page proxy that requests the page serverside and provide the page from your own domain ...

in case it is not for a public webpage you could give your script special privileges (browser dependent) to achieve your goal ... but that couldn't be really controlled for public pages ...

kind regards
Jul 24 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.