Sam wrote:
> After retrieving a URL using an Ajax.Request...
>  
> function onComplete (request, json) {
> // request.responseText holds the entire page
>  
> Only the content contained in elementID = 'source' is intended for display
>  
> At this time, the following code works, but it disturbingly copies the 
> entire page from the source URL into the target DIV
>  
> $('target').innerHTML = request.responseText; // copy the entire page
> $('target').innerHTML = $('source').innerHTML; // remove everything bur 
> the content of element 'source'
>  
> Any suggestion for a method to copy only the innerHTML of 'source'  ?

Mark wrote:
>You'd probably have to use Javascript's regular expression matching
>to extract the section of the page text string that's inside the tag
>having the id="source" attribute.

Ack!  I was hoping I could manipulate the incoming stuff with more of an
"out of <body>" experience.

oMyDiv = document.createElement('div'); // this div isn't attached to the
dom

oMyDiv.innerHTML = request.responseText ; // Stuff the external page URL
into this DIV

// hocus pocus... 
$('target').innerHTML = oMyDiv.getElementByID('source').innerHTML ;  // in
your dreams

My understanding is that until the incoming 'source' HTML is attached to the
DOM, it stays as HTML and isn't OO.  If this is right, then yes, I'd need a
regEx.

I'm off to the regEx forum for assistance.  This problem is what regEx was
created for.  Anyone have a regEx to pull the content of element 'source'
out of a page?

Thomas - thanks for your comments.  I'm stuck reading html from a
non-scripting server, so I've got to do this the hard way, but thanks.

Sam



_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to