• 强制使用office web Apps新建文档


    2011-10-25 备注

    RegisterSod(key,url)   key首字母不能大写,否则就执行不成功,原因不明

    sharepoint 2010 (sp1)在安装了office客户端的情况下,就不会使用webapps创建文档,通过调试脚本,最后得到是收到下图脚本的影响,当浏览器能够检测到OpenDocment的ActiveX加载项时,会调用createNewInClient调用客户端Office,否则使用createNewInBrowser调用webapps。

    image

    var event = new Object(); event.fromRibbon=true; event.currentCtx = eval('ctx' + currentCtxId); 
    CoreInvoke ('createNewDocumentWithRedirect2',event,'http:\u002f\u002fzhfd-portaldev\u002fDocs\u002fDocuments\u002fForms 
    \u002ftemplate.dotx', 'http:\u002f\u002fzhfd-portaldev\u002fDocs\u002fDocuments', 'SharePoint.OpenDocuments', 
    false, 'http://zhfd-portaldev/Docs/_layouts/CreateNewDocument.aspx?id=http://zhfd-
    portaldev/Docs/Documents/Forms/template.dotx', true, 1);

    image

    image

    想到实现强制使用Webapps创建文档,可以通过代替默认的createNewDocumentWithRedirect()完成,通过页面脚本,发现core.js是通过

    <script type="text/javascript">RegisterSod("sp.core.js", "\u002f_layouts\u002fsp.core.debug.js?rev=Qp5K7ycU\u00252FEY9IvE0KOi7zQ\u00253D\u00253D");</script>

    注册到页面的,我们要做的就是把自定义脚本注册在core.js的后面。

    解决方案:

    image

    1.添加一个脚本文件rj.js

    写入修改后的createNewDocumentWithRedirect():

    function createNewDocumentWithRedirect(strTemplate, strSaveLocation, strProgID, bXMLForm, strRedirectUrl, sron, defaultItemOpen) {
        ULSrLq: ;
        if (sron) {
            createNewInBrowser(strRedirectUrl, strSaveLocation, strProgID, defaultItemOpen);
        }
    } 

    2.添加一个EmptyElement,将注册脚本写在CustomAction里:

    <CustomAction Id="Ribbon.Library.Actions.NewButton.Script"
        Location="ScriptLink"
        ScriptBlock="
        function  _rjJs(){
          //注册自定义脚本
          RegisterSod('rj.js', '/_layouts/TGPortal/rj.js');
          //作为core.js的附属
          RegisterSodDep('sp.ui.dialog.js', 'core.js');
          //加载脚本
          LoadSodByKey('rj.js', '');
        }    
        function _rjLoad1()
        {
          //在Core.js加载完成后执行_rjJs()
          ExecuteOrDelayUntilScriptLoaded(_rjJs, 'core.js');
        }
        //将脚本设定为BodyOnload完成后执行
        _spBodyOnLoadFunctionNames.push('_rjLoad1');
      " />
    3.部署解决方案,使用Chrome的开发人员工具测试createNewDocumentWithRedirect是否为自定义的脚本
    image
  • 相关阅读:
    vue苦逼自学之路
    第一次博客作业
    u3d学习资料
    leetcode——Divide Two Integers
    leetcode——Swap Nodes in Pairs
    leetcode——Merge k Sorted Lists
    leetcode——Container With Most Water
    leetcode——Regular Expression Matching
    leetcode——Longest Palindromic Substring
    CC_CALLBACK之间的区别
  • 原文地址:https://www.cnblogs.com/ruijian/p/2195551.html
Copyright © 2020-2023  润新知