Different behaviours when script included or called

  • Thread starter Yves-Alain NICOLLET
  • Start date
Y

Yves-Alain NICOLLET

How is it that when I include a script within a document it works and
when I try to get it from my webserver it does not seem to work at
all?

I have documents on my webserver that contain a script of the form:

<script language=JavaScript>
javascript statements...
</script>

This works OK.

When I put all the scripts statements in a file called
/cgi-bin/myScript.js on the webserver and replace the script in the
document with the phrase:

<script language=text/JavaScript src=/cgi-bin/myScript.js></script>

nothing works anymore.

Any idea?
Thanks.
 
R

Randy Webb

Yves-Alain NICOLLET said:
How is it that when I include a script within a document it works and
when I try to get it from my webserver it does not seem to work at
all?

I have documents on my webserver that contain a script of the form:

<script language=JavaScript>
javascript statements...
</script>

This works OK.

When I put all the scripts statements in a file called
/cgi-bin/myScript.js on the webserver and replace the script in the
document with the phrase:

<script language=text/JavaScript src=/cgi-bin/myScript.js></script>

nothing works anymore.

Because it should be:

<script type="text/javascript" src="/cgi-bin/myScript.js"></script>

There is no language text/JavaScript. Its type.
 
P

Peter Vernout

Randy Webb said:
Because it should be:

<script type="text/javascript" src="/cgi-bin/myScript.js"></script>

There is no language text/JavaScript. Its type.

It could also be that your webserver is trying to execute the js file
instead of serving it to the browser for executing there (hence cgi-bin).
try placing it on another path.
 
Y

Yves-Alain NICOLLET

Peter Vernout said:
It could also be that your webserver is trying to execute the js file
instead of serving it to the browser for executing there (hence cgi-bin).
try placing it on another path.

I simply changed all that to:

<script src=/scripts/myScript.js>

and everything went smooth, since the webserver maps .js files to
application/x-javascript.

Thank you everybody.
 
M

Michael Winter

On 26 Apr 2004 01:41:38 -0700, Yves-Alain NICOLLET

[snip]
<script src=/scripts/myScript.js>

That is still invalid. Not only because you omit a *required* type
attribute, but you don't quote the src attribute value. It *is* necessary
as only a limited character set can exist outside of quotes. A forward
slash is one such excluded character. Whilst your browser might cope with
it fine, not all will. As a general rule, quote *everything*. It's easier
than remembering what's valid and what isn't.

Mike
 
T

Thomas 'PointedEars' Lahn

Yves-Alain NICOLLET said:
I simply changed all that to:

<script src=/scripts/myScript.js>

and everything went smooth, since the webserver maps .js files to
application/x-javascript.

It is nevertheless incorrect. Unquoted attribute values must not contain
the "/" character (attribute values that contain "/" must be quoted) and
the "type" attribute is mandatory for valid HTML 4.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top