Accessing javascript variable from another site?

L

leppert

Hello,

I am trying to access a javascript variable on another site. The site
requires the user to be logged in, so what I am doing is submitting a
form and redirecting the output to an IFRAME, which has a blank page
with a script block containing the variable I need access to.

However, when trying to access the variable, I get access is
denied/permission is denied error, due to the site being on another
domain (my page is actually hosted locally on the user's machine). I've
tried adding to trusted sites, etc. to no avail.

Is there anyway to accomplish what I am trying to do, without having to
resort to something exotic like custom activex control etc?
 
R

Randy Webb

(e-mail address removed) said the following on 8/17/2006 5:10 PM:
Hello,

I am trying to access a javascript variable on another site. The site
requires the user to be logged in, so what I am doing is submitting a
form and redirecting the output to an IFRAME, which has a blank page
with a script block containing the variable I need access to.

However, when trying to access the variable, I get access is
denied/permission is denied error, due to the site being on another
domain (my page is actually hosted locally on the user's machine). I've
tried adding to trusted sites, etc. to no avail.

Is there anyway to accomplish what I am trying to do, without having to
resort to something exotic like custom activex control etc?

Do an HTTPRequest submit of the form. It is also called "AJAX".

There are other ways as well.
 
J

Jon

Randy said:
(e-mail address removed) said the following on 8/17/2006 5:10 PM:

Do an HTTPRequest submit of the form. It is also called "AJAX".

There are other ways as well.

Any pointers or links on how to accomplish this?

Thanks!
 
T

TKapler

it is not possible using javascript only, it works only in IE, not in
other browsers, thanks to security threads. Maybe you can do it using
e.g. combination of php and javascript - download the page from other
server using php to your server and then access anything on it
 
R

Randy Webb

TKapler said the following on 8/18/2006 4:51 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

it is not possible using javascript only,

Yes, it is quite possible.
it works only in IE,

If it is not possible, then how can it "work only in IE"? And your
statement that it is only possible in IE is wrong anyway.
not in other browsers,

Wrong again.
thanks to security threads.

Wrong again.
Maybe you can do it using e.g. combination of php and javascript
- download the page from other server using php to your server
and then access anything on it

You could do it with a combination of server side and client side
scripting but I can do it with pure client side scripting. And, it is
quite trivial at that.
 
T

TKapler

Randy said:
Please quote what you are replying to.
sorry, i do not forgot that ggroups are often used also by mail. But
anyway in my groups we have rights to not include the text we reply to,
if it is the original sender

Yes, it is quite possible.

You are definitely better programmer than I am, but as far as i know
and as far as i read, javascript can only access pages in the same
domain. And I have tried several times with standard ajax routines and
with iframe and they all worked the same way - with no problems on IE,
but with security error in Opera and FF. I understand this security
problem, a hacker can try to open in e.g. hidden iframe with your bank
account/mails etc. and if you are logged in the same session, it would
allow him to show the content, so he could read it/manipulate it.
I have read the coresponding articles about that security messages on
FF and Opera forums, because for one intranet project i need to solve
it and both browsers have settings to allow this.
So If you say it is possible to access variable of the page on
different domain with the default settings on all browsers, i would
really welcome a code example, i could imediately use it in my
projects.

Thank you
Tomas
 
B

Bart Van der Donck

TKapler said:
[...]
You are definitely better programmer than I am, but as far as i know
and as far as i read, javascript can only access pages in the same
domain. And I have tried several times with standard ajax routines and
with iframe and they all worked the same way - with no problems on IE,
but with security error in Opera and FF. I understand this security
problem, a hacker can try to open in e.g. hidden iframe with your bank
account/mails etc. and if you are logged in the same session, it would
allow him to show the content, so he could read it/manipulate it.
I have read the coresponding articles about that security messages on
FF and Opera forums, because for one intranet project i need to solve
it and both browsers have settings to allow this.

Well, if you lower your browser security settings to the
"Are-you-nuts"-level, cross-domain scripting should work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top