Question

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.

Was it helpful?

Solution

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>

OTHER TIPS

Why you should not try like this:

<script type="text/javascript" src="server-name/style library/scripts/xyz.js></scripts>
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top