Adding js to masterpage question
-
21 มิถุนายน 2555 16:35
Hi
I am trying to add some custom javascript to my masterpage (v4.master), to show a banner. The javascript is:
The javascript is (you can see the popup at the top):
Can I just add all of the below to the bottom of the page, just before the closing of the body tag?
<script type="text/javascript">
function cookiesDirectiveScriptWrapper(){
// Cookie creating scripts etc here....
}
</script>
<script type="text/javascript" src="http://js.cookiesdirective.com/1.5.js" />
<script type="text/javascript">
// The position of the disclosure ('top' or 'bottom')
// Number of times to display disclosure. Enter 0 to show it forever!!!!
// The URI of your privacy policy
cookiesDirective('top',5,'privacy.html');
</script>
Thanks
ตอบทั้งหมด
-
21 มิถุนายน 2555 16:37Yeah. It should work
Ashish Ranjan (Please click "Marked As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you)
-
21 มิถุนายน 2555 20:20
I would recommend wrapping your script up in a .js file, uploading that file somewhere in your SharePoint site, and then referencing it in your masterpage. This way, you can edit the javascript independently of your masterpage.
Of course, always backup your masterpage before modifying it. -
22 มิถุนายน 2555 15:58
Yeah I normally do that, Matthew.
I tried this by adding the code as is to the bottom of the masterpage, but I get a Correlation ID error (which cannot be found).
-
22 มิถุนายน 2555 17:56
Enable page level error tracing and make custom error off, by editing web config. That will display you exact error detail. I feel, it must be some missing tag or small issue.Ashish Ranjan (Please click "Marked As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you)
- ทำเครื่องหมายเป็นคำตอบโดย Entan MingMicrosoft, Moderator 29 มิถุนายน 2555 11:41
-
22 มิถุนายน 2555 19:27Have you tried adding your script within the <head> tags? There should be a placeholder called PlaceHolderAdditonalPageHead in your master page.
Manaz Mohideen - MCPD, MCITP, MCTS