Connecting Tech Pros Worldwide Help | Site Map

Accessing javascript variable from another site?

  #1  
Old August 17th, 2006, 10:05 PM
leppert@insight.rr.com
Guest
 
Posts: n/a
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?

  #2  
Old August 17th, 2006, 10:15 PM
Randy Webb
Guest
 
Posts: n/a

re: Accessing javascript variable from another site?


leppert@insight.rr.com said the following on 8/17/2006 5:10 PM:
Quote:
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
  #3  
Old August 17th, 2006, 10:15 PM
Jon
Guest
 
Posts: n/a

re: Accessing javascript variable from another site?



Randy Webb wrote:
Quote:
leppert@insight.rr.com said the following on 8/17/2006 5:10 PM:
Quote:
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.
>
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Any pointers or links on how to accomplish this?

Thanks!

  #4  
Old August 18th, 2006, 09:45 AM
TKapler
Guest
 
Posts: n/a

re: Accessing javascript variable from another site?


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

  #5  
Old August 18th, 2006, 04:25 PM
Randy Webb
Guest
 
Posts: n/a

re: Accessing javascript variable from another site?


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.

<URL: http://www.safalra.com/special/googlegroupsreply/ >
Quote:
it is not possible using javascript only,
Yes, it is quite possible.
Quote:
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.
Quote:
not in other browsers,
Wrong again.
Quote:
thanks to security threads.
Wrong again.
Quote:
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.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
  #6  
Old August 18th, 2006, 08:55 PM
TKapler
Guest
 
Posts: n/a

re: Accessing javascript variable from another site?



Randy Webb wrote:
Quote:
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

Quote:
Quote:
it is not possible using javascript only,
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

  #7  
Old August 19th, 2006, 08:45 AM
Bart Van der Donck
Guest
 
Posts: n/a

re: Accessing javascript variable from another site?


TKapler wrote:
Quote:
[...]
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.

--
Bart

Closed Thread