19 Agu 2016

Simple Workaround for Content Editor Webpart in Another Site Collection

Guess what? You have created a HTML script stored somewhere in SharePoint, and you want to use it somewhere in another Site Collection. But you are stuck with this error, “Cannot retrieve the URL specified in the Content Link property. For more assistance, contact your site administrator”.

image

There are a few workarounds you can try.

Using Page Viewer or IFRAME

To use the page viewer, the solution is quite straight-forward and can be described in a few sentences.

Firstly, you know that you have created the HTML script, now create a page in the same Site Collection, then add Content Editor Webpart that links to the HTML script.

Then you can go to the other Site Collection, create a page with Page Viewer, or direct HTML with IFRAME which links to the page created in previous step. Remember, the SharePoint top links bar and left navigation will still be displayed. To overcome that, you can add query string “IsDlg=1” at the end of the URL.

If your URL is like: http://contoso.com/Pages/cewp.aspx, then it should be like http://contoso.com/Pages/cewp.aspx?IsDlg=1.

Using jQuery

If your masterpage is attached with jQuery, you can re-use the following code.

<div class="pp-container">
</div>
<script type="text/javascript">
 $.ajax({
  url: "/SiteAssets/common/thescripts.txt",
  method: "GET",
  success: function (data) {
   $('div.pp-container').append(data);
  },
  error: function (data) {
   console.log("Error:");
   console.log(data);
  }
 });
</script>

Where "/SiteAssets/common/thescripts.txt" is the URL of your HTML script.

Tidak ada komentar:

Posting Komentar

[give me your ideas, hopes, comments and compliments below...]
[aaand...... +1 if you need to....]