Solved

SharePoint MasterPage and Javscript error

Posted on 2013-01-05
5
711 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 31

Accepted Solution

by:
Jamie McAllister MVP earned 250 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 31

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
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)

705 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now