0

I'm adding a web part(farm solution) into SharePoint 2013, the problem that I am receiving is that any scripting link I add(specifically jquery in this example), doesn't seem to be found by internet explorer 10. This works fine in chrome. I know I could add the CDN for jquery but there are other custom JS files I'm using and they also have the same issue.

I have added the JavaScript files in Style Library.

<script type="text/javascript" src= "<asp:Literal runat='server' 
Text='<% $SPUrl:~sitecollection/Style Library/Scripts/jquery-1.11.1.min.js %>'/>">
</script> 

<script type="text/javascript" src= "<asp:Literal runat='server' 
Text='<% $SPUrl:~sitecollection/Style Library/Scripts/project.js %>' />"></script> -->

<script>
alert($().jquery)
</script>

In ie 10 I get

Error: '$' is undefined

while the version gets printed in chrome.

So the jquery library that I linked, doesn't seem to be working. Why is this happening and what should I do to make it work in IE.

2 Answers 2

1

This is working on my dev environment from a long time. I guess issue is with single and double inverted commas. Check this

<script type="text/javascript" src='<SharePoint:EncodedLiteral runat="server" Text="<%$SPUrl:~sitecollection/Style%20Library/Scripts/jquery-1.11.1.min.js%>" />'></script>

<script type="text/javascript" src='<SharePoint:EncodedLiteral runat="server" Text="<%$SPUrl:~sitecollection/Style%20Library/Scripts/project.js%>" />'></script>
0

Why you should not try like this:

<script type="text/javascript" src="server-name/style library/scripts/xyz.js></scripts>
2
  • 1
    using the ~sitecollection, actually adds the server-name. I'm not hardcoding the server-name because it changes. Sep 23, 2014 at 6:47
  • Yes, you correct about that part, then just give the relative path like style library.scripts/xyz.js only. remove the tag like ~site pr ~sitecollection
    – ateet
    Sep 23, 2014 at 7:03

Your Answer

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

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