Force use office web Apps to create a document

Source: Internet
Author: User

2011-10-25 remarks

RegisterSod (key, url) the first letter of the key cannot be in upper case. Otherwise, the operation fails. The reason is unknown.

Sharepoint 2010 (sp1) does not use webapps to create documents when the office client is installed. After debugging the script, it is affected by the script, when the browser detects the OpenDocment ActiveX add-on, it will call createNewInClient to call the client Office; otherwise, it will use createNewInBrowser to call webapps.

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);

To use Webapps to create a document, replace the default createNewDocumentWithRedirect () and use the page script to find that core. js uses

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

To register to the page, we need to register the Custom Script behind core. js.

Solution:

1. Add a script file rj. js

Write the modified createNewDocumentWithRedirect ():

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

2. Add an EmptyElement and write the registration script in CustomAction:

<CustomAction Id = "Ribbon. library. actions. newButton. script "Location =" ScriptLink "ScriptBlock =" function _ callback JS () {// register the Custom Script RegisterSod ('rj. js', '/_ layouts/TGPortal/rj. js'); // serves as the core. js affiliated RegisterSodDep ('SP. ui. dialog. js', 'core. js '); // load the script LoadSodByKey ('rj. js', '');} function _ uploload1 () {// in Core. after js loading is complete, execute _ response js () ExecuteOrDelayUntilScriptLoaded (_ response js, 'core. js ');} // set the script to BodyOnload and execute _ spBodyOnLoadFunctionNames. push ('_ upload1'); "/>

3. Deploy the solution. Use Chrome's Developer Tools to test whether createNewDocumentWithRedirect is a custom script.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.