admin管理员组

文章数量:1402433

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 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

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. 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

Share Improve this question asked Aug 4, 2016 at 17:19 GreybeardTheUnreadyGreybeardTheUnready 2651 gold badge5 silver badges16 bronze badges 6
  • What do you see in the network tab? – SLaks 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 – GreybeardTheUnready 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 ? – jeremy-denis 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 !!!! – GreybeardTheUnready 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. – GreybeardTheUnready Commented Aug 4, 2016 at 18:20
 |  Show 1 more ment

2 Answers 2

Reset to default 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...

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...

本文标签: htmlEdge not loading some javascriptStack Overflow