[Zope] RSS and JavaScript

John Morton John Morton <jwm@plain.co.nz>
Mon, 8 Jan 2001 16:11:16 +1300 (NZDT)


On 7 Jan 2001 17:51:24 -0800 LARRY CHUON <lchuon@telocity.com> wrote:

> Hi Zopistas,
> 
> Happy New Year!
> 
> I'm working with SiteSummary and would like htmlPreview to grab the URL
> and open it up in a new window.  It's not working correct.  I'm unsure
> how Zope handle javascript either.

Zope handles javascript in the same way it handles html - it just sends
it to the client and let's the browser figure out what to do with it.
DTML, on the other hand, is interpreted beforehand, and the results are
sent to the browser. 

>  Any help is greatly appreciated. 
> Below is my htmlPreview.  I also tried to put the javascript function
> (I'm new to js as well) in a file and import it to the same directory as
> standard_html_header.  Then I add <SCRIPT LANGUAGE="JavaScript"
> SRC="openMe.js"></SCRIPT> to stand_html_header.  That doesn't work
> either. By the way, js doesn't seen to work well in Zope.  I could n't
> find much info on-line.  

[cut]
> <P><A href="javascript:openMe('<dtml-var url html_quote>')"><dtml-var linktext html_quote></A>

My understanding of what happens when this link is traversed is that the
browser calls the javascript function 'openMe(...)', which should already
defined in the page. It doesn't attempt to fetch anything from the server
with that URL.

So what you need to do is ensure that htmlPreview include the function
openMe by either including the code into the html document like this:

<script language="JavaScript">
<dtml-var name="openMe_js">
</script>

(note that I've replaced the dot in openMe.js with an underscore, as
objects with dots in there ids need to be quoted to be used, and 
1) I've forgotten how to do it
2) Searching through the documentation has given me a headache
)

...Or do what you did before:

<SCRIPT LANGUAGE="JavaScript" SRC="<dtml-var expr="openMe_js.absolute_url()">"></SCRIPT>

Use the absolute_url() method, so that the browser is sure of getting the
right url for the script (which may have been your problem before).

I'd use the first method as you can at least eyeball the html output of
htmlPreview and see if the openMe function has acutally been include,
before having to use whatever passes for javascript debugging in your
browser.

HTH,
John