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]

Reply via email to