תשובה Adding js to masterpage question

  • יום חמישי 21 יוני 2012 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):

    http://cookiesdirective.com

    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 יוני 2012 16:37
     
     
    Yeah. 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 יוני 2012 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 יוני 2012 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 יוני 2012 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)

  • יום שישי 22 יוני 2012 19:27
     
     
    Have 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