SRC parameter not working in Mozilla when path is included

W

wylbur37

I normally use Mozilla 1.4 on Windows XP Pro.
As I was developing some test webpages, I discovered that the SRC
parameter doesn't seem to work when a path is used with the filename.

In one example, when I want to run a JavaScript from an external file
(i.e., not inline), I would do the following ...

<SCRIPT LANGUAGE="JavaScript" SRC="program.js"> </SCRIPT>

If "program.js" were in a different subdirectory than the .htm file
referring to it, the filename would have to be prefixed by the
pathname as follows ...

<SCRIPT LANGUAGE="JavaScript" SRC="/mydir/program.js"> </SCRIPT>

But when I ran the above from within an .htm file loaded locally into
Mozilla, it did not work. (The result was as if the above code weren't
there). However, when I ran the identical code on Internet Explorer
(v.6), it worked.


In another, even simpler example, the code to put an image on a
webpage is ...

<img src="picture.jpg">

Again, if "picture.jpg were in a different subdirectory than the .htm
file referring to it, the filename would have to be prefixed by the
pathname as follows ...

<img src="/mydir/picture.jpg">

When I ran the above from within an .htm file loaded locally into
Mozilla, it did not work. (The result was as if the above code weren't
there). However, when I ran the identical code on Internet Explorer
(v.6), it worked.


By the way, I tried using backslashes instead of forward slashes. In
both cases, it still worked on Internet Explorer but not on Mozilla.


The SRC parameter seems like a fairly frequently used parameter for
the developers of Mozilla to overlook it. Is this really a bug in
Mozilla or is it just some option/switch in Mozilla that I didn't set
properly?
 
H

Hywel Jenkins

I normally use Mozilla 1.4 on Windows XP Pro.
As I was developing some test webpages, I discovered that the SRC
parameter doesn't seem to work when a path is used with the filename.

What's the URL of your site?
 
L

Lasse Reichstein Nielsen

As I was developing some test webpages, I discovered that the SRC
parameter doesn't seem to work when a path is used with the filename.

I doubt that. Such a bug would have been caught very quickly.
In one example, when I want to run a JavaScript from an external file
(i.e., not inline), I would do the following ...

<SCRIPT LANGUAGE="JavaScript" SRC="program.js"> </SCRIPT>

You should use type="text/javascript" instead of language="JavaScript".
It is both forward and backward compatible, and has the advantage of
beging valid HTML 4.
If "program.js" were in a different subdirectory than the .htm file
referring to it, the filename would have to be prefixed by the
pathname as follows ...

<SCRIPT LANGUAGE="JavaScript" SRC="/mydir/program.js"> </SCRIPT>

Are you sure you don't mean:
<SCRIPT LANGUAGE="JavaScript" SRC="mydir/program.js"> </SCRIPT>
(no initial "/").
That would put the script in a subdirectory of the directory of
the HTML file. With the initial slash, the path is no longer relative
to the HTML file, but absolute on the server. That is, if your HTML
file is
http://www.example.com/somedir/otherdir/mypage.html
then SRC="/mydir/program.js" refers to:
http://www.example.com/mydir/program.js
while SRC="mydir/program.js" refers to:
http://www.example.com/somedir/otherdir/mydir/program.js
You could even use the relative SRC="../mydir/program.js" to refer to:
http://www.example.com/somedir/mydir/program.js
But when I ran the above from within an .htm file loaded locally into
Mozilla, it did not work. (The result was as if the above code weren't
there). However, when I ran the identical code on Internet Explorer
(v.6), it worked.

Running locally (i.e., with the file:protocol) and using absolute
paths is bound to give trouble.
The SRC parameter seems like a fairly frequently used parameter for
the developers of Mozilla to overlook it. Is this really a bug in
Mozilla or is it just some option/switch in Mozilla that I didn't set
properly?

Try describing your directory structure, then I can say whether it is
a bug. I have not had any problems with Mozilla (currently using
Firebird 0.7 for testing and as backup for my main browser)

/L
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top