1

I have a website that works fine on Chrome and FF, but fails on Edge. When I look at the Console log (on Edge) it tells me certain javascript functions are undefined, if I switch the default Edge developer tool's debugger on I can see that one of my js files hasn't been loaded, but others have (See below). Console Log on FF and chrome report no errors or warnings. The page header is set to <!DOCTYPE html> and the js is included like this...

<script src="js/generalUtils.js" type="text/javascript"></script>
<script src="js/dlmUtils.js" type="text/javascript"></script>
<script src="js/md5.js" type="text/javascript"></script>

generalUtils.js and login.js load, but dlmUtils.js does not get loaded. (nb There are also a bunch of 'remote' js loaded from ajax.googleapis.com successfully.)

The javascript in dlmUtils.js runs fine in Chrome and FF and does not report any errors or warnings on the console.

Thoughts?

jonb

6
  • What do you see in the network tab? Commented Aug 4, 2016 at 17:21
  • Good point... Unfortunately no clue there. It reports dlmUtils exactly the same as all other local scripts that work, i this case loaded in 46.74ms Commented Aug 4, 2016 at 17:41
  • If you look in the source code of the page is your link to the file dlmUtils.js correct ? Can you open it ? Commented Aug 4, 2016 at 17:51
  • This is bizarre, The <script src='js\dlmUtils.js' shows up in the debugger window and does open, but in 'file explorer' type window to the left lists all scripts except dlmUtils.js !!!! Commented Aug 4, 2016 at 17:56
  • UPDATE: I think I'm on the track - chopping out all the content of dlmUtils.js the problem goes away. Adding the content back in a bit at a time it seems to be related to one (fairly large) function - I will report back when I've pinpointed the actual culprit. Commented Aug 4, 2016 at 18:20

2 Answers 2

4

Bizarre - I discovered that in fact the script was being loaded, but then quickly dumped. It turns out that Edge doesn't like defaulting parameters in Javascript. - I guess I missed a standards memo somewhere :-)

function showJobsheet(id=0) {

caused Edge to dump the script, so now...

function showJobsheet(id) {
    id = ((typeof id !== 'undefined') ? id : 0);

This is the only change I've had to make and now everything works fine.

Thanks to all who offered help...

Sign up to request clarification or add additional context in comments.

2 Comments

Default parameters are supported only in Microsoft Edge with experimental JavaScript features enabled (about:flags). msdn.microsoft.com/en-us/library/yh6c50h7(v=vs.94).aspx
Same happened to me when using the JavaScript coalescing operator, something like let countryDropDownEnabled = $(this).data("iscountryenabled") ?? "True"; I changed to the regular if...then...else alternative and worked fine.
0

I was having this same problem. I was able to pin it down as Edge "dumping" the JS file as GreybeardTheUnready said by having the Edge dev tools open and showing the directory where the JS file should be. When refreshing the page, it does show in that directory momentarily, and then disappears.

Even with the experimental JavaScript features enabled, this was happening because I was using JavaScript's optional chaining (?.). Removed those question marks and the JS file now sticks around. Unfortunately it means I have to make my code more verbose...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.