Forums / Install & configuration / How to link external Javascript files?

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

How to link external Javascript files?

Author Message

Gerhard Hoogterp

Tuesday 18 February 2003 3:34:56 am

While converting a site to ez3 I found a number of gotcha's for external files. Basicly css and js files.

The CSS can be handled by

<link href={"stylesheets/general.css"|ezdesign} rel="stylesheet" type="text/css" />

where the stylesheets directory is under design/slo/ (in this case) No problem there. background images in the CSS style can be found using relative paths (../images) which solves most of my problems there.

Javascript files are more problematic.

Mozilla reports:

Error: syntax error
Source File: http://ezslo.slo.nl/design/slo/javascript/screen.js
Line: 2
Source Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

The path is ok, that's where the file is. Of course it doesn't contain a DOCTYPE line so where thatone comes from is beond me.

The call is made through:

<script language="JavaScript" src={"javascript/screen.js"|ezdesign} type="text/javascript">
</script>

which works as it should outside of ez.

Who can shine some light here? Thanks.

Tony Wood

Tuesday 18 February 2003 4:42:39 am

> While converting a site to ez3 I found a number of gotcha's
> for external files. Basicly css and js files.
>
> The CSS can be handled by
>
> <link href={&#034;stylesheets/general.css&#034;|ezdesign}
> rel="stylesheet" type="text/css" />
>
> where the stylesheets directory is under design/slo/ (in
> this case) No problem there. background images in the CSS
> style can be found using relative paths (../images) which
> solves most of my problems there.
>
> Javascript files are more problematic.
>
> Mozilla reports:
>
> Error: syntax error
> Source File:
> http://ezslo.slo.nl/design/slo/javascript/screen.js
> Line: 2
> Source Code:
> <!DOCTYPE html PUBLIC &#034;-//W3C//DTD XHTML 1.0
> Transitional//EN"
>
> The path is ok, that's where the file is. Of course it
> doesn't contain a DOCTYPE line so where thatone comes from
> is beond me.
>
> The call is made through:
>
> <script language=&#034;JavaScript&#034;
> src={&#034;javascript/screen.js&#034;|ezdesign}
> type=&#034;text/javascript&#034;>
> </script>
>
> which works as it should outside of ez.
>
> Who can shine some light here? Thanks.

Try adding |js to your http conf insert for the site. By default .js files are not allowed. If you add them they then work.

i.e. change
RewriteRule !\.(gif|css|jpg|png)$
to
RewriteRule !\.(gif|css|jpg|png||js)$

While your there probably best to add |ico for .ico files so you can get your favicon working :)

Tony

Tony Wood : twitter.com/tonywood
Vision with Technology
Experts in eZ Publish consulting & development

Power to the Editor!

Free eZ Training : http://www.VisionWT.com/training
eZ Future Podcast : http://www.VisionWT.com/eZ-Future

Gerhard Hoogterp

Tuesday 18 February 2003 4:55:23 am

> i.e. change
> RewriteRule !\.(gif|css|jpg|png)$
> to
> RewriteRule !\.(gif|css|jpg|png||js)$
>
> While your there probably best to add |ico for .ico files so
> you can get your favicon working :)

And gif as there's still a lot of it around.. Thanks, completely forgot about those setting.

Kristoffer Karlsson

Wednesday 16 November 2005 4:00:02 am

In which file am I supposed to change this?

> RewriteRule !\.(gif|css|jpg|png)$
> to
> RewriteRule !\.(gif|css|jpg|png||js)$

_____________________________________
Blog: http://www.kristofferkarlsson.com
Website: http://www.spelkanalen.com

Mark Marsiglio

Wednesday 16 November 2005 5:21:22 am

This is either in an .htaccess file in your root directory (enable viewing of files that begin with a period in your FTP client), or your httpd.conf. Unless you own the server and have root access, the .htaccess is the most likely file to change.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions