zoukankan      html  css  js  c++  java
  • SharePoint:ScriptLink测试

    最终结论

    <SharePoint:ScriptLink  ID="SPlink1"  Name="sp.ui.tgportal.js"   Defer="false"  runat="server" OnDemand="false" Localizable="true" />
    defer: 决定是否及时输出,默认为“false”,“true”为最后输出;
    OnDemand:

    决定是否由“RegisterSod”进行注册,如果使用注册,则页面加载完后不马上加载js,而是在调用函数前要进行加载,比如使用SP.SOD.executeFunc("sp.ui.tgportal.js", null, alert(0));

    Localizable: 决定是否要在2052中查找js,false是直接在layouts中查找;
    LoadAfterUI: 决定在head中输出还是在body完成前

    参考:http://www.ilovesharepoint.com/2010/08/sharepoint-scripts-on-demand-spsod.html

             Sharepoint JS CSS 注册

    2011-12-30添加

    SharePoint:ScriptLink在内部调用的也是  ClientScript.RegisterStartupScript RegisterClientScriptBlock RegisterClientScriptInclude

    通过js路径来判断是否未重复注册

    page2.ClientScript.RegisterStartupScript(typeof(ScriptLink), str, info.ToScriptBlock(page));

    str = ExtractFilename(name) + localizable.ToString();

    =========================================================

                             部分测试数据

    =========================================================

    <SharePoint:ScriptLink ID="SPlink1" Name="sp.ui.tgportal.js" Defer="false" runat="server"  />
    </head>

    结果: header附近

    25:document.write('<script type="text/javascript" src="/_layouts/2052/init.js?rev=rcZULplQ2sjYL0GwamiLEQ%3D%3D"></' + 'script>');
    26:document.write('<script src="/_layouts/2052/sp.ui.tgportal.js?rev=pLpSQ6vSUCg3DEmdOme1fQ%3D%3D"></' + 'script>');

    =========================================================

    <SharePoint:ScriptLink ID="SPlink1" Name="sp.ui.tgportal.js" Defer="true" runat="server" />
    </head>

    结果: RegisterSod之前

    <script type="text/javascript">
    // <![CDATA[
    document.write('<script src="/_layouts/2052/sp.ui.tgportal.js?rev=pLpSQ6vSUCg3DEmdOme1fQ%3D%3D"></' + 'script>');
    // ]]>
    </script>
    <script type="text/javascript">RegisterSod("sp.core.js",…

    =================================================================

    <SharePoint:ScriptLink  ID="SPlink1"  Name="sp.ui.tgportal.js"   Defer="true"  runat="server" OnDemand="true" /></head>

    <SharePoint:ScriptLink  ID="SPlink1"  Name="sp.ui.tgportal.js"   Defer="false"  runat="server" OnDemand="true"  />

    结果:

    <script type="text/javascript">RegisterSod("core.js", "\u002f_layouts\u002f2052\u002fcore.js?rev=KpeTWMrqjCSYYu4RiO0\u00252B1Q\u00253D\u00253D");</script>
    <script type="text/javascript">RegisterSod("sp.ui.tgportal.js",

    ==========================================================

    <SharePoint:ScriptLink  ID="SPlink1"  Name="sp.ui.tgportal.js"   Defer="true"  runat="server" OnDemand="false" Localizable="true" />

    </head>

    结果:

    <script type="text/javascript">
    // <![CDATA[
    document.write('<script src="/_layouts/2052/sp.ui.tgportal.js?rev=pLpSQ6vSUCg3DEmdOme1fQ%3D%3D"></' + 'script>');
    // ]]>
    </script>
    <script type="text/javascript">RegisterSod("sp.core.js",

    ===========================================================

    <SharePoint:ScriptLink  ID="SPlink1"  Name="sp.ui.tgportal.js"   Defer="false"  runat="server" OnDemand="false" Localizable="true" />

    结果:

    25:document.write('<script type="text/javascript" src="/_layouts/2052/init.js?rev=rcZULplQ2sjYL0GwamiLEQ%3D%3D"></' + 'script>');
    26:document.write('<script src="/_layouts/2052/sp.ui.tgportal.js?rev=pLpSQ6vSUCg3DEmdOme1fQ%3D%3D"></' + 'script>');

  • 相关阅读:
    【原】从/dev/null重新打开标准输出
    Go 接口转换的一个例子
    关于软件编译安装的出错处理
    【原】GO 语言常见错误
    HP平台由于变量声明冲突导致程序退出时的core
    动态链接库加载出错:cannot restore segment prot after reloc: Permission denied
    Windows VC++常见问题汇总
    .net:System.Web.Mail vs System.Net.Mail应该用哪个
    网络管理的功能
    Hello World! — 用 Groovy 编写的 Java 程序
  • 原文地址:https://www.cnblogs.com/ruijian/p/2224651.html
Copyright © 2011-2022 走看看