Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SharePoint MasterPage and Javscript error

Posted on 2013-01-05
5
Medium Priority
?
734 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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 …
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

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