In my masterpage, I've loaded a simple javascript file from /_layouts/myfolder/myjs.js - and the script loads and runs in Firefox (even in different instances and with different plugins) but not in IE 10, nor in Chrome.

The script is just this:


The popup blocker is disabled, and Security Zone is set to low. Javascript is enabled.

I've tried regular old js script links, and I've also tried the delayed loading, like this:

<SharePoint:ScriptLink ID="myScriptLink" runat="server" Name="/_layouts/mylib/myscript.js" LoadAfterUI="true" OnDemand="false"/>

What could cause this?

  • 1
    Have you cleared the browser cache? – Robert Lindgren Jul 18 '13 at 17:14
  • Yes - I cleared everything. The master loads - I can see the stylesheets working. – bgmCoder Jul 18 '13 at 18:09
  • 1
    Could it be related to the security zone? – Robert Kaucher Jul 18 '13 at 18:34
  • 1
    Does it help if you wrap it in a method that you call from ExecuteOrDelayUntilScriptLoaded or any other body onload event? Or is it just when it is unwrapped that it is not executed? – Robert Lindgren Jul 18 '13 at 18:54
  • 1
    Ah, sorry fellas. I'm a dunce. I added the /* to comment out the script, but I didn't scroll down far enough to see that another comment cancelled the comment. Which means it actually is working and there is something else wrong in the script. I'm going to delete my question. Thanks for helping. – bgmCoder Jul 18 '13 at 18:55

I am used to coding in autohotkey where I can do this by way of optional parameters:

somefunction(parameter, optionalparam="aConstant"){
   ;some stuff

However you can't do it that way in Javascript. Instead you do it like this:

function somefunction(parameter, otherparameter){
         otherparamteter = something;

Apparently, Firefox will still run the parts of the script that haven't yet failed. IE and Chrome both dump the entire script and don't do anything at all. That means that an alert("bob"); at the top of the script will always run in Firefox, even if part of the code below it is wrong - but in IE and Chrome, nothing happens.


| improve this answer | |

Try to load jquery and fire alert inside ready function of Jquery and check.

Also, it can possible if you already added jquery in master page and something conflict on page load thats why not working in IE.

If possible, show me your head portion of master page.

| improve this answer | |
  • The OP has already given the answer below – Robert Lindgren Jul 19 '13 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.