Archive for JavaScript

Dynamically load JavaScript file

Sometimes you don’t always want a JavaScript file to load. If, for instance, a control that utilises it is loaded by a page that already references the same JavaScript file, you wouldn’t want to load the script file again.

Note: This being a SharePoint blog, the script shown here is tailored for that platform but will quite easily port to other non SharePoint sites.

A good example of this would be a custom SharePoint WebPart that uses jQuery. Now, say you don’t have control over the page that will host the WebPart and therefore can’t guarantee that the jQuery script will be present in the page\master page\delegate header control. You could dynamically load the script file as the WebPart loads. The problem with this is that the rendering page might already be loading the same script.

Also, by loading the jQuery script file, especially in an environment you have little control over (maybe a WebPart you developed, which is used by many different systems and configurations) you could potentially cause a conflict on the use of the $ alias, which jQuery creates by default.
Read more

Unable to set value of the property ‘aSettings’

I developed a page, inheriting from LayoutsPageBase which was being displayed in a modal dialog using JavaScript similar to the following:

<script type="text/javascript">
    function DisplayCustomPopupPage() {
        var options = SP.UI.$create_DialogOptions();
        options.url = "http://urltocustompage/page.aspx";
        options.title = "Popup Page";
        options.allowMaximize = false;
        options.showClose = true;
        options.width = 800;
        options.height = 450;

The DisplayCustomPopupPage function would be called from a click event on the page.

The popup page had an InputFormTextBox control on it that was configured for rich text mode.

The problem I encountered with this was a JavaScript error that said ‘null’ is null or not an object or Unable to set value of the property ‘aSettings’: object is null or undefined.
Read more

Hide All Site Content Link

Looking for a straight forward and relatively easy way of hiding the All Site Content link from the quick launch area?

All you need to do is create a feature, manisfest file and user control that contains the script to hide the link.

The feature should ideally be site or web scoped although it doesn’t really matter and depends where you want the link removed from.

Create a new empty element file and replace with the following content:
Read more


Get every new post delivered to your Inbox

Join other followers: