Solved

SharePoint MasterPage and Javscript error

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i make the array into an object? 4 34
Else condition 9 19
Jquery 2 13
jQuery - Add confirm message to button? 2 7
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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)

803 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