You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Robby Pelssers <ro...@ciber.com> on 2009/06/04 10:19:59 UTC

how-to reference external js from cocoon 2.2 block

Hi all,

 

I'm a bit puzzled about how to reference an external javascript file.

 

Let's say I've put it in

 

src/main/resources/external/js/test.js 

 

I thought about referencing it the same way as my css file but somehow
this does not work.  Can someone explain how I can accomplish this?  Now
adding the <script> line in my xslt gives me an empty html page.

 

Thx in advance,

Robby

 

  <xsl:template match="/">

      <html>

        <head>

          <meta http-equiv="Content-Type"
content="text/html;charset=UTF-8" />

          <title>My Cocoon block</title>

          <link type="text/css" rel="stylesheet"
href="resource/external/css/styles.css"></link>

          <script type="text/javascript"
src="resource/external/js/test.js"></script>

        ...

 </xsl:template>      

 

 


RE: how-to reference external js from cocoon 2.2 block

Posted by Robby Pelssers <ro...@ciber.com>.
Thx a lot Joachim,

You saved me a lot of headache ;-)

I knew it was somehow related to cocoon because if I would copy-paste the generated code in a plain .html file it would render without any problems.  I just didn't know the exact cause.

Cheers mate !!

Robby

-----Original Message-----
From: Jasha Joachimsthal [mailto:j.joachimsthal@onehippo.com] 
Sent: Thursday, June 04, 2009 10:40 AM
To: users@cocoon.apache.org
Subject: Re: how-to reference external js from cocoon 2.2 block

2009/6/4 Robby Pelssers <ro...@ciber.com>:
> Hi all,
>
>
>
> I'm a bit puzzled about how to reference an external javascript file.
>
>
>
> Let's say I've put it in
>
>
>
> src/main/resources/external/js/test.js
>
>
>
> I thought about referencing it the same way as my css file but somehow this
> does not work.  Can someone explain how I can accomplish this?  Now adding
> the <script> line in my xslt gives me an empty html page.
>
>
>
> Thx in advance,
>
> Robby
>
>
>
>   <xsl:template match="/">
>
>       <html>
>
>         <head>
>
>           <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"
> />
>
>           <title>My Cocoon block</title>
>
>           <link type="text/css" rel="stylesheet"
> href="resource/external/css/styles.css"></link>
>
>           <script type="text/javascript"
> src="resource/external/js/test.js"></script>
>
>         ...
>
>  </xsl:template>
>

You're probably using some variant of the XMLSerializer which "closes"
the script HTML tag. Browsers don't get that and render empty pages
although the view source does display all HTML. Add a &#160; in the
script tag.


Jasha Joachimsthal

j.joachimsthal@onehippo.com - jasha@apache.org

www.onehippo.com
Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466
San Francisco - Hippo USA Inc. 101 H Street, suite Q Petaluma CA
94952-5100 +1 (707) 773-4646

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: how-to reference external js from cocoon 2.2 block

Posted by Jasha Joachimsthal <j....@onehippo.com>.
2009/6/4 Robby Pelssers <ro...@ciber.com>:
> Hi all,
>
>
>
> I’m a bit puzzled about how to reference an external javascript file.
>
>
>
> Let’s say I’ve put it in
>
>
>
> src/main/resources/external/js/test.js
>
>
>
> I thought about referencing it the same way as my css file but somehow this
> does not work.  Can someone explain how I can accomplish this?  Now adding
> the <script> line in my xslt gives me an empty html page.
>
>
>
> Thx in advance,
>
> Robby
>
>
>
>   <xsl:template match="/">
>
>       <html>
>
>         <head>
>
>           <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"
> />
>
>           <title>My Cocoon block</title>
>
>           <link type="text/css" rel="stylesheet"
> href="resource/external/css/styles.css"></link>
>
>           <script type="text/javascript"
> src="resource/external/js/test.js"></script>
>
>         …
>
>  </xsl:template>
>

You're probably using some variant of the XMLSerializer which "closes"
the script HTML tag. Browsers don't get that and render empty pages
although the view source does display all HTML. Add a &#160; in the
script tag.


Jasha Joachimsthal

j.joachimsthal@onehippo.com - jasha@apache.org

www.onehippo.com
Amsterdam - Hippo B.V. Oosteinde 11 1017 WT Amsterdam +31(0)20-5224466
San Francisco - Hippo USA Inc. 101 H Street, suite Q Petaluma CA
94952-5100 +1 (707) 773-4646

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org