Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SharePoint MasterPage and Javscript error

Posted on 2013-01-05
5
Medium Priority
?
737 Views
Last Modified: 2013-01-13
Hello all,

I'm working on a client request to allow them to edit a mission statement place in the header and edit the footer. What comes to mind to allow this to happen is using SPServices to show the information from a list. Right now, instead of placing javascript file it in a CEWP, I wanted place it in the masterPage so that it can carry through out the website. Unfortunately, I keep getting errors when I try to reference my javascript file.

I get a "Cannot make a cache safe URL" when I reference use <SharePoint:ScriptLink>, a "Syntax Error" when using a <script> tag and it doesn't show up at all when I reference the the file in <asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server"> tag. Thanks

I'm using a javascript test file that has an alert("I'm in"); that I have tested and I know it works. I may be missing something on how to reference a javascript file in a SharePoint masterpage. Please let me know if I'm doing something wrong.
0
Comment
Question by:Isaac
5 Comments
 
LVL 32

Accepted Solution

by:
Jamie McAllister MVP earned 750 total points
ID: 38748201
Would the Reusable Content list be a valid alternative approach?

http://office.microsoft.com/en-001/sharepoint-server-help/use-reusable-content-HA010163838.aspx

As for your issue above, there are several possible causes listed here;

http://www.enjoysharepoint.com/Articles/Details/cannot-make-a-cache-safe-url-for-filename-file-not-194.aspx
0
 
LVL 5

Author Comment

by:Isaac
ID: 38749332
Error on pageThanks but I don't think reusable content will be an approach I will pursue. Even when I reference the js file correctly, I get a syntax error. Attach is want I'm receiving.
0
 
LVL 32

Expert Comment

by:Jamie McAllister MVP
ID: 38750139
I've seen this before when the encoding was different. Open your file in Notepad and try saving it as ANSI and UTF8 and see if that changes things. Failing on the first character can hint at something like that.
0
 
LVL 14

Assisted Solution

by:KoenVosters
KoenVosters earned 750 total points
ID: 38750164
I would first of all work with a delegate control where you plug in the javascript:

http://fyeomans.com/2011/05/16/make-your-sharepoint-2010-master-page-extensible-with-delegate-controls/
0
 

Expert Comment

by:Officelabs_LarryK
ID: 38762367
I'm not sure why you would use SPServices when a straight forward dataview webpart would do the same job here.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question