1

What is missing in the code to hide "Chrome type" = none?

enter image description here

var siteUrl = '/sites/RU_test';
var serverRelativeUrl = '/sites/RU_test/SitePages/Test.aspx';
function addWebPart() {
var clientContext = new SP.ClientContext(siteUrl);
var oFile = clientContext.get_web().getFileByServerRelativeUrl(serverRelativeUrl);
var limitedWebPartManager = oFile.getLimitedWebPartManager(SP.WebParts.PersonalizationScope.shared);
var webPartXml = '<?xml version=\"1.0\" encoding=\"utf-8\"?>' + 
    '<WebPart xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"' + 
    ' xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"' + 
    ' xmlns=\"http://schemas.microsoft.com/WebPart/v2\">' + 
    '<Title>Template</Title><FrameType>Default</FrameType>' + 
    '<Description>Use for formatted text, tables, and images.</Description>' + 
    '<IsIncluded>true</IsIncluded><ZoneID></ZoneID><PartOrder>0</PartOrder>' + 
    '<FrameState>Normal</FrameState><Height /><Width /><AllowRemove>true</AllowRemove>' + 
    '<AllowZoneChange>true</AllowZoneChange><AllowMinimize>true</AllowMinimize>' + 
    '<AllowConnect>true</AllowConnect><AllowEdit>true</AllowEdit>' + 
    '<AllowHide>true</AllowHide><IsVisible>true</IsVisible><DetailLink /><HelpLink />' + 
    '<HelpMode>Modeless</HelpMode><Dir>Default</Dir><PartImageSmall />' + 
    '<MissingAssembly>Cannot import this Web Part.</MissingAssembly>' + 
    '<PartImageLarge>/_layouts/images/mscontl.gif</PartImageLarge><IsIncludedFilter />' + 
    '<Assembly>Microsoft.SharePoint, Version=13.0.0.0, Culture=neutral, ' + 
    'PublicKeyToken=94de0004b6e3fcc5</Assembly>' + 
    '<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>' + 
    '<ContentLink xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\">' + '/sites/RU_test/SiteAssets/template.js</ContentLink>' + 
    '<Content xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\">' + 
    '<![CDATA[This is a first paragraph!<DIV>&nbsp;</DIV>And this is a second paragraph.]]></Content>' + 
    '<PartStorage xmlns=\"http://schemas.microsoft.com/WebPart/v2/ContentEditor\" /></WebPart>';
var oWebPartDefinition = limitedWebPartManager.importWebPart(webPartXml);
this.oWebPart = oWebPartDefinition.get_webPart();
limitedWebPartManager.addWebPart(oWebPart, 'Left', 1);
clientContext.load(oWebPart);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
alert('Web Part added: ' + oWebPart.get_title());
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
2

Hello the Chrome Type is managed by the tag

**<FrameType>None</FrameType>**

which in your code is set to

<FrameType>Default</FrameType>

you need to set it as none then it will work as aspected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.