Welcome to WebmasterWorld Guest from 54.226.246.160

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

External JavaScript Files

Mac O/S 9 IE 5 Does not seem to support External JavaScript Files

     

rcsmoss

12:46 pm on Apr 30, 2003 (gmt 0)

10+ Year Member



I am using external javascript files in some new web page designs I am creating. The following id the tag syntax in the head of each page:

<script language="javascript" src="/jsfiles/filename.js"></script>

This all works fine on any PC with either IE 6 or Netscape 7. The problems start to arise when trying to view these pages on a Mac running either O/S 9 or O/S 10 with IE 5. The pages all dispay okay but none of the javascript functions work. It seems as though the Mac's do not understand the use of an external javascript file. I am also using external CSS style sheets which do work.

Do I have to re-include all the javascript code in each page to work correctly on Mac's?

BlobFisk

1:00 pm on Apr 30, 2003 (gmt 0)

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Welcome to WebmasterWorld, rcsmoss!

Try removing the first / from your scr call, so that it looks like:

src="jsfiles/filename.js"

The leading / tells the browser to use site relative pathing (ie, go up to the site root and work your way down). I'd guess that you are using document relative pathing (from the documents location, follow this path), which omits the leading /.

Also, you should use the type attribute (language is deprecated):

type="text/javascript"

HTH

ShawnR

1:19 pm on Apr 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you have spaces in your filenames? New browsers substitute spaces for %20 before sending the requet to the server, but older browsers don't, so that is one possibility.

Another possibility is that the javascript file is being read, but not executing because of some incompatibility between DOM implementations.

Try an alert("hello world\n"); at the top of your external javascript file to see if the problem is with the file not being read vs a problem in the javascript in the file.

Shawn

BlobFisk

1:50 pm on Apr 30, 2003 (gmt 0)

WebmasterWorld Senior Member blobfisk is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Do you have any comment tags at the start of the external javascript file?

ShawnR's suggestion of the alert at the top of the script is a very good one - as he says, at least you'll know then if the script is being read or not.

Macguru

2:04 pm on Apr 30, 2003 (gmt 0)

WebmasterWorld Senior Member macguru is a WebmasterWorld Top Contributor of All Time 10+ Year Member



>>The pages all dispay okay but none of the javascript functions work.

If none of the above works, you could also try to have a look at the browsers preferences to check if JS is activated.

Edit/Preferences/Web Browser/Web Content/Active Content/check Active sripting

rcsmoss

5:25 pm on Apr 30, 2003 (gmt 0)

10+ Year Member



I have done all of the suggested options in regard to the following:

<script language="javascript" type="text/javascript" src="/jsfiles/filename.js"></script>

I have also tried putting the external file in the same directory as the other files, no difference.

1. Yes the files is there because it works on with a pc browser
2. Yes the file is where I think it is
3. Yes the path name is correct otherwise it would not work on a pc
4. No, the js file does not contain any html tags or comments since I just removed them as well.

Thanks for all your great suggestions, keep them coming....

[edited by: WebGuerrilla at 5:36 pm (utc) on April 30, 2003]
[edit reason] No Specifics Please [/edit]

Macguru

5:36 pm on Apr 30, 2003 (gmt 0)

WebmasterWorld Senior Member macguru is a WebmasterWorld Top Contributor of All Time 10+ Year Member



<!-- Did you read BlobFisk's message # 4? // -->

rcsmoss

8:47 am on May 1, 2003 (gmt 0)

10+ Year Member



Finally - All is well.

Apparently when you refresh a pc browser it not only re-loads the current page but also reloads any external source files (CSS .js).

On the Mac, however, this is not the case. Refresh only re-loads the current page and not any external source files.

Turns out the problem was one of my form validation functions. I have since replaced this function with a new one and all works great on both PC and Mac.

Thanks again to all who gave their time and suggestions.

RM

 

Featured Threads

Hot Threads This Week

Hot Threads This Month