RE: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Shawn Grover
One method would be to include Page B with a _javascript_ include (script src="" and have Page B put the string you're after into a _javascript_ variable.After the include, your code can see that variable as if it were on the same page.

 
I'm sure there's more elegant solutions though.

 
Shawn

-Original Message-
From: Nikhil Madani [mailto:[EMAIL PROTECTED]
Sent: Friday, March 12, 2004 1:20 PM
To: CF-Talk
Subject: _javascript_: Retrieving Remote HTML

I know this forum might not be the most relevant place for _javascript_ help, but anyway here is my problem:

On a certain page A, I have a _javascript_ function that needs to retrieve
HTML code from another web page B, possibly on another server.I know for a fact that the page I'm trying to reach will output a single string and I need to set a _javascript_ variable with that value.

(For those curious, this other page is a cfm page where I create a string
value based on the url params)

Any ideas?

TIA
Nik 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Nikhil Madani
That's definitely possible, but I surely cannot do an script src="" from within a _javascript_ functionis there
a way I could assign the js variable (created on page B)to a global scope that I can then 
access inside any _javascript_ function on page A?

 One method would be to include Page B with a _javascript_ include 
 (script src="" and have Page B put the string you're 
 after into a _javascript_ variable.After the include, your code can 
 see that variable as if it were on the same page.

 
 
 I'm sure there's more elegant solutions though.

 
 
 Shawn
 
 -Original Message-
 From: Nikhil Madani [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 12, 2004 1:20 PM
 To: CF-Talk
 Subject: _javascript_: Retrieving Remote HTML
 
 
 I know this forum might not be the most relevant place for _javascript_ 
 help, but anyway here is my problem:
 
 On a certain page A, I have a _javascript_ function that needs to 
 retrieve
 HTML code from another web page B, possibly on another server.I know 
 for a fact that the page I'm trying to reach will output a single 
 string and I need to set a _javascript_ variable with that value.
 
 (For those curious, this other page is a cfm page where I create a 
 string
 value based on the url params)
 
 Any ideas?
 
 TIA
 Nik 

 _

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Gaulin, Mark
Check out IFRAMEs
http://www.oreillynet.com/pub/a/_javascript_/2002/02/08/iframe.html
http://www.oreillynet.com/pub/a/_javascript_/2002/02/08/iframe.html 

 
I haven't used them yet but it might be just what you're looking for.

 
 Mark

-Original Message-
From: Nikhil Madani [mailto:[EMAIL PROTECTED]
Sent: Friday, March 12, 2004 3:36 PM
To: CF-Talk
Subject: Re: _javascript_: Retrieving Remote HTML

That's definitely possible, but I surely cannot do an script
src="" from within a _javascript_ functionis there
a way I could assign the js variable (created on page B)to a global scope
that I can then 
access inside any _javascript_ function on page A?

 One method would be to include Page B with a _javascript_ include 
 (script src="" and have Page B put the string you're 
 after into a _javascript_ variable.After the include, your code can 
 see that variable as if it were on the same page.

 
 I'm sure there's more elegant solutions though.

 
 Shawn
 
 -Original Message-
 From: Nikhil Madani [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 12, 2004 1:20 PM
 To: CF-Talk
 Subject: _javascript_: Retrieving Remote HTML
 
 
 I know this forum might not be the most relevant place for _javascript_ 
 help, but anyway here is my problem:
 
 On a certain page A, I have a _javascript_ function that needs to 
 retrieve
 HTML code from another web page B, possibly on another server.I know 
 for a fact that the page I'm trying to reach will output a single 
 string and I need to set a _javascript_ variable with that value.
 
 (For those curious, this other page is a cfm page where I create a 
 string
 value based on the url params)
 
 Any ideas?
 
 TIA
 Nik 

 _
 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Barney Boisvert
You can't make HTTP requests with _javascript_.However, you can use a hidden
frame to do the dirty work.Create a hidden frame, set it's location to
your URL, then check the content of it's document to get the output from the
url (what you need) and set it to your variable. Just be careful, because
setting the location is an asyncronous operation, so it'll return
immediately.You'll have to use setTimout or setInterval to keep checking
the hidden frame's document source to see when the request is finished
processing.

Cheers,
barneyb

 -Original Message-
 From: Nikhil Madani [mailto:[EMAIL PROTECTED] 
 Sent: Friday, March 12, 2004 12:36 PM
 To: CF-Talk
 Subject: Re: _javascript_: Retrieving Remote HTML
 
 That's definitely possible, but I surely cannot do an script 
 src="" from within a _javascript_ functionis there
 a way I could assign the js variable (created on page B)to a 
 global scope that I can then 
 access inside any _javascript_ function on page A?
 
  One method would be to include Page B with a _javascript_ include 
  (script src="" and have Page B put the string you're 
  after into a _javascript_ variable.After the include, your code can 
  see that variable as if it were on the same page.

  
  I'm sure there's more elegant solutions though.

  
  Shawn
  
  -Original Message-
  From: Nikhil Madani [mailto:[EMAIL PROTECTED]
  Sent: Friday, March 12, 2004 1:20 PM
  To: CF-Talk
  Subject: _javascript_: Retrieving Remote HTML
  
  
  I know this forum might not be the most relevant place for 
 _javascript_ 
  help, but anyway here is my problem:
  
  On a certain page A, I have a _javascript_ function that needs to 
  retrieve
  HTML code from another web page B, possibly on another 
 server.I know 
  for a fact that the page I'm trying to reach will output a single 
  string and I need to set a _javascript_ variable with that value.
  
  (For those curious, this other page is a cfm page where I create a 
  string
  value based on the url params)
  
  Any ideas?
  
  TIA
  Nik 

  _
  
 

 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: JavaScript: Retrieving Remote HTML

2004-03-12 Thread bret
Is this the sort of thing you're looking for?

http://jibbering.com/2002/4/httprequest.html

-Bret

 -Original Message-
 From: Nikhil Madani [mailto:[EMAIL PROTECTED]

 I know this forum might not be the most relevant place for _javascript_
 help, but anyway here is my problem:

 On a certain page A, I have a _javascript_ function that needs to
 retrieve
 HTML code from another web page B, possibly on another server.I know
 for a fact that the page I'm trying to reach will output a single
 string and I need to set a _javascript_ variable with that value.
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Nikhil Madani
Interesting..can't hurt to try it out! Only drawbacsk seems to be how different browsers handle the IFRAME element.
Thanks Mark...

(P.S- To others reading this message- I'd still be interested to know if you've got a different take on this issue...(no offense to you Mark))

Check out IFRAMEs
http://www.oreillynet.com/pub/a/_javascript_/2002/02/08/iframe.html
http://www.oreillynet.com/pub/a/_javascript_/2002/02/08/iframe.html 
 
I haven't used them yet but it might be just what you're looking for.
 
 Mark

-Original Message-
From: Nikhil Madani [mailto:[EMAIL PROTECTED]
Sent: Friday, March 12, 2004 3:36 PM
To: CF-Talk
Subject: Re: _javascript_: Retrieving Remote HTML


That's definitely possible, but I surely cannot do an script
src="" from within a _javascript_ functionis there
a way I could assign the js variable (created on page B)to a global scope
that I can then 
access inside any _javascript_ function on page A?

 One method would be to include Page B with a _javascript_ include 
 (script src="" and have Page B put the string you're 
 after into a _javascript_ variable.After the include, your code can 
 see that variable as if it were on the same page.


 
 I'm sure there's more elegant solutions though.



 _
 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Rob
On Fri, 2004-03-12 at 12:19, Nikhil Madani wrote:
 I know this forum might not be the most relevant place for _javascript_ help, but anyway here is my problem:
 
 On a certain page A, I have a _javascript_ function that needs to retrieve
 HTML code from another web page B, possibly on another server.I know for a fact that the page I'm trying to reach will output a single string and I need to set a _javascript_ variable with that value.
 
 (For those curious, this other page is a cfm page where I create a string
 value based on the url params)
 
 Any ideas?
Newer _javascript_ can load xml files - which I had no idea, but man its
cool. If you can make the document you are getting an XML document you
can try this:

make a variable - where to get the xml

var xmlsource=http://www.yoursite.net/newsEngine/index.cfm?s=2;

then build an xml document loader (yes it works on firefox and mozilla -
I wouldnt know it if it didnt :-D )

if (window.ActiveXObject)
	var xmlDoc = new ActiveXObject(Microsoft.XMLDOM)
else if (document.implementation  document.implementation.createDocument)
	var xmlDoc = document.implementation.createDocument(,doc,null)

then load it
if (typeof xmlDoc != undefined)
{
	xmlDoc.load(xmlsource)
}

after that you can do normal DOM stuff on it i.e.

tickerobj = xmlDoc.getElementsByTagName(xmlticker)[0]

It's a really great trick I have used it several times. I dont think it
works back to netscape 4 (or windows 3.11 for that matter :)

I learned this by ripping apart this ticker script
http://www.dynamicdrive.com/dynamicindex2/xmlticker2.htm

Rememeber to set cfcontent type to text/xml.

Hope that helps

-- 
Rob [EMAIL PROTECTED]
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Nikhil Madani
I found this exact same page in my search too
Will have to try it out. My only worry is the part where the author says...depends on version of MSXML installed. Now I'm not sure which versions of IE come with MSXML or if its a feature the client will have to download and install to access the page properly.
Will research this a bit more. The other problem I have with what Barney and others have suggested with the IFRAME and FRAME thing is that, the IFRAME will load as soon as the client page loads up. The page I will be accessing using IFRAME sets a variable that is timestamp dependent. Finally when the _javascript_ function (which needs one of its variable set thru the IFRAME) is called (dependent on when the client clicks a link for example), the variable is stale. If I can tolerate an indefinite time delay, I would not jump thru all these hoops and simply call a script src="" with the src page returning the entire _javascript_ function.

I hope that made some sense whatsoever :)
Is this the sort of thing you're looking for?

http://jibbering.com/2002/4/httprequest.html

-Bret


 -Original Message-
 From: Nikhil Madani [mailto:[EMAIL PROTECTED]
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Rob
On Fri, 2004-03-12 at 13:19, Nikhil Madani wrote:
 I found this exact same page in my search too
 Will have to try it out. My only worry is the part where the author says...depends on version of MSXML installed. 

If it helps any I've tested that script with:
Win2k IE5  6
WinXP IE whatever
WinXP Mozilla
Linux Mozilla (1.~4)
Linux Firefox (new)

If you want can try it here if you'd like:
http://www.thealgorithm.net/index.cfm
That is a *highly* alpha site (mostly proof of concept and testing
stuff) but you can see if it works for your set up.

-- 
Rob [EMAIL PROTECTED]
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Gaulin, Mark
Xml fetching and parsing all in one... that *is* cool. 

 
Re IFRAME: the url for the iframe can be loaded dynamically at any time via
scripting, and does not require a visible screen element. At least that's
what I've read. 

-Original Message-
From: Rob [mailto:[EMAIL PROTECTED]
Sent: Friday, March 12, 2004 5:05 PM
To: CF-Talk
Subject: Re: _javascript_: Retrieving Remote HTML

On Fri, 2004-03-12 at 12:19, Nikhil Madani wrote:
 I know this forum might not be the most relevant place for _javascript_
help, but anyway here is my problem:
 
 On a certain page A, I have a _javascript_ function that needs to retrieve
 HTML code from another web page B, possibly on another server.I know for a
fact that the page I'm trying to reach will output a single string and I
need to set a _javascript_ variable with that value.
 
 (For those curious, this other page is a cfm page where I create a string
 value based on the url params)
 
 Any ideas?
Newer _javascript_ can load xml files - which I had no idea, but man its
cool. If you can make the document you are getting an XML document you
can try this:

make a variable - where to get the xml

var xmlsource=http://www.yoursite.net/newsEngine/index.cfm?s=2;

then build an xml document loader (yes it works on firefox and mozilla -
I wouldnt know it if it didnt :-D )

if (window.ActiveXObject)
var xmlDoc = new ActiveXObject(Microsoft.XMLDOM)
else if (document.implementation  document.implementation.createDocument)
var xmlDoc = document.implementation.createDocument(,doc,null)

then load it
if (typeof xmlDoc != undefined)
{
xmlDoc.load(xmlsource)
}

after that you can do normal DOM stuff on it i.e.

tickerobj = xmlDoc.getElementsByTagName(xmlticker)[0]

It's a really great trick I have used it several times. I dont think it
works back to netscape 4 (or windows 3.11 for that matter :)

I learned this by ripping apart this ticker script
http://www.dynamicdrive.com/dynamicindex2/xmlticker2.htm

Rememeber to set cfcontent type to text/xml.

Hope that helps

-- 
Rob [EMAIL PROTECTED] 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Shawn Grover
So, besides the XML approach (which sounds VERY interesting), there are two methods suggested.I've done both myself, and personally prefer the IFrames.

 
The first method would be something like so:

 
script src="">
script
x = js_string_set_in_pageB.cfm;
/script

 
The second would be something like so:
script
 var TargetString
 document.getElementById(myIFrame).src = "">
/script

 
And Page be would be something like this:

 
... some CF Code ...
script
 window.parent.TargetString = #Some Value#;
/script

(Notice the variable is being set in the IFrame itself - this way you don't have to worry about the Asynchronous issues, and can even call functions on the parent page (which you sometimes have to do to make sure the values you are working with stay in the proper memory scope - it's a pain to refer to a variable that was set in a window/iframe that was then closed or changed).

 
I would recommend one of the above two methods, but would also suggest exploring the XML.

 
Hope this helps.

 
Shawn

-Original Message-
From: Nikhil Madani [mailto:[EMAIL PROTECTED]
Sent: Friday, March 12, 2004 1:55 PM
To: CF-Talk
Subject: Re: _javascript_: Retrieving Remote HTML

Interesting..can't hurt to try it out! Only drawbacsk seems to be how different browsers handle the IFRAME element.
Thanks Mark...

(P.S- To others reading this message- I'd still be interested to know if you've got a different take on this issue...(no offense to you Mark))

Check out IFRAMEs
http://www.oreillynet.com/pub/a/_javascript_/2002/02/08/iframe.html
http://www.oreillynet.com/pub/a/_javascript_/2002/02/08/iframe.html 
 
I haven't used them yet but it might be just what you're looking for.
 
 Mark

-Original Message-
From: Nikhil Madani [mailto:[EMAIL PROTECTED]
Sent: Friday, March 12, 2004 3:36 PM
To: CF-Talk
Subject: Re: _javascript_: Retrieving Remote HTML


That's definitely possible, but I surely cannot do an script
src="" from within a _javascript_ functionis there
a way I could assign the js variable (created on page B)to a global scope
that I can then 
access inside any _javascript_ function on page A?

 One method would be to include Page B with a _javascript_ include 
 (script src="" and have Page B put the string you're 
 after into a _javascript_ variable.After the include, your code can 
 see that variable as if it were on the same page.


 
 I'm sure there's more elegant solutions though.



 _
 
_ 
_
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




RE: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Peter Tilbrook
Is it just me or are a few parts of the MM site down (JRun
Updater/Developers Home...)

 
--
Peter Tilbrook
ColdFusion Applications Developer
ColdGen Internet Solutions
Manager, ACT and Region ColdFusion Users Group - http://www.actcfug.com
http://www.actcfug.com/ 
4/73 Tharwa Road
Queanbeyan, NSW, 2620
AUSTRALIA

Telephone: +61-2-6284-2727
Mobile: +61-0439-401-823
E-mail: [EMAIL PROTECTED]

World Wide Web: http:/www.coldgen.com/
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]




Re: JavaScript: Retrieving Remote HTML

2004-03-12 Thread Nikhil Madani
Cool folks...thanks a lotI'm going to getting working on all these
ideas. Once again, thanks for your inputs
 [Todays Threads] 
 [This Message] 
 [Subscription] 
 [Fast Unsubscribe] 
 [User Settings]