开发者

javascript namespacing in sharepoint 2010 master page

开发者 https://www.devze.com 2023-02-18 15:13 出处:网络
I have made an custom master page in a Sharepoint Foundation site, and i would to insert custom javascript using namespacing.

I have made an custom master page in a Sharepoint Foundation site, and i would to insert custom javascript using namespacing. this is my code:

 <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.min.js"></script>
 <script type="text/javascript">
     var CapMossJs = {
         setCurrentMonthInCombo: function () {
             //var objComboMesi = getField('select', 'Mese');   
             var datCurrent = new Date();
             var intCurrMonth = datCurrent.getMonth();
            window.alert(intCurrMonth);
        },

         hideUtenteSrcurlTemplatelink: function() {
         }
     }      
 </script>
 <script type="text/javascript">
     $().ready(function () {
         CapMossJs.setCurrentMonthInCombo();
     });
 </script>

that i have inserted in the master page after the lines

 id="onetidPageTitleAreaFrameScript"
 if (document.getElementById("onetidPageTitleAreaFrame") != null)   {
   document.getElementById("onetidPageTitleAreaFrame").className="ms-areaseparator";

after line 491 in practice. In a normal page made with visual studio 2010 this code works, instead in the master page i have an error from jquery that the property or method is not supported from object: could someone explain why ? without namespacin开发者_JAVA技巧g there are no problems.


You can't put a script tag inside another script tag, and none of the code that you add should be inside that if statement.


The same code without namespacing works without problems, the two lines relative to the "if" are only a reference of the place in code , if you open with SharePoint Designer a custom form it will be clear: in every case my scripts tags are after line 491 , where there is already another script tag.

0

精彩评论

暂无评论...
验证码 换一张
取 消