Sunday, June 25, 2017

Javascript: Why can't I access the '../..' directory in browser on mac

Leave a Comment

A client-side JS program includes the following lines:

<script src='../../LIBS/jwlib.js'></script> <script src ='../js/header.js'></script> <script src ='../js/session.js'></script> <script src ='../js/classes.js'></script> <script src ='../js/main.js'></script> 

It runs properly on any browser under Windows. But on my iMac it fails because it fails to find a function defined in jwlib. And jwlib is not found by Chrome Developer Tools.

What's going wrong?

The program itself is at http://www.johnwheater.net/JAVASCRIPT/MULTIBODY/html/main.html

Thanks, Hugues and Chetan, for your interest. On loading, we should see a canvas with two squares, one blue and one black. The blue one should show a collection of numbers between 1 and 50, and a button labelled BEGIN. When you press that button the numbers should start dashing about.

This does not happen on my iMac, and Chrome Devtools reports a missing function get_random_integer(). If you put a breakpoint on line 366 of main.js you see the call, and the failure when you continue.

This function is in the file jwlib.js, which is not found.

I have made a new version, with the missing function pasted into main.js. That is called MULTIBODY2 rather than MULTIBODY, and it works. as described.

1 Answers

Answers 1

Sorry for the time wasting..

The problem is that I thought window.onload() would be called only when all the scripts had been loaded.

This seems not to be the case, and my problem was just a difference in timing between mac and windows.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment