Prev: FAQ Topic - Internationalisation and Multinationalisation in javascript. (2010-03-23)
Next: FAQ Topic - How do I format a Date object with javascript? (2010-03-28)
From: Mahdi Rad on 27 Mar 2010 18:29 for example there is site with address www.X.com, that has the price of some product: <div id="product1">price: 100$</div> now I wanna make site www.Y.com and then, I wanna read the price of product1 which is in the site www.X.com we can read the value in the html site with javascript command like this: String s = document.getElementById("product1").value but how can we read this value in out of that site? the improtant thing is : do it with code, beucause I wanna update my site automatically can anybody help me?
From: Garrett Smith on 27 Mar 2010 19:06 Mahdi Rad wrote: > for example there is site with address www.X.com, that has the price > of some product: > <div id="product1">price: 100$</div> > now I wanna make site www.Y.com and then, I wanna read the price of > product1 which is in the site www.X.com > we can read the value in the html site with javascript command like > this: > String s = document.getElementById("product1").value > but how can we read this value in out of that site? > Use a proxy. Your server can make a request to x.com to request the price. Define this in a "getAPrice" server side program. Your *page* makes a request to your "getAPrice" program, which then requests to other domain. If you are using JSP, c:import tag is a very simple way to write a proxy server. A less robust approach is to use dynamic script insertion to append script tag with src using x.com domain. > the improtant thing is : do it with code, beucause I wanna update my > site automatically > To automatically update, you can poll periodically. Somebody else may be able to explain more about persistent connection, but I'm guessing that what I wrote will be enough. -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/
From: johnwlockwood on 27 Mar 2010 19:41 On Mar 27, 5:29 pm, Mahdi Rad <radma...(a)gmail.com> wrote: > can anybody help me? Mahdi, we were just talking about this in another thread. Sean Kinsey has a library to help with this sort of thing easyXDM ( http://easyxdm.net/ ) If for site X.com, you cannot upload files to it's server, you can use a bookmarklet to initiate the appropriate javascript. Sean just wrote an example http://easyxdm.net/wp/2010/03/27/creating-a-bookmarklet-with-easyxdm/ also the FAQ for this group talks about cross domain scripting http://jibbering.com/faq/#frameRef
From: Thomas 'PointedEars' Lahn on 28 Mar 2010 06:50 johnwlockwood wrote: > Mahdi Rad wrote: >> can anybody help me? > > Mahdi, we were just talking about this in another thread. What other thread are you talking about? > Sean Kinsey has a library to help with this sort of thing easyXDM [...] I have looked at it, and what you are saying appears to be unlikely. For a start, for this statement to have a chance to become true, he would need to stop using features that are not universally available, and stop misusing proprietary properties of host objects. > If for site X.com, you cannot upload files to it's server, you can use > a bookmarklet to initiate the appropriate javascript. Sean just wrote > an example [...] The OP's question is essentially about a *download* (retrieving information), not about an upload (sending information). A working solution (transparent HTTP proxying) has been proposed already. PointedEars -- Danny Goodman's books are out of date and teach practices that are positively harmful for cross-browser scripting. -- Richard Cornford, cljs, <cife6q$253$1$8300dec7(a)news.demon.co.uk> (2004)
From: Sean Kinsey on 28 Mar 2010 07:33
On Mar 28, 12:50 pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de> wrote: > I have looked at it, and what you are saying appears to be unlikely. For a > start, for this statement to have a chance to become true, he would need to > stop using features that are not universally available, and stop misusing > proprietary properties of host objects. If you are referring to the easyXDM library, could you elaborate on this? Why should it not use features that is not universally available when it provides fallbacks where not, and which proprietary properties is it misusing? |