Archive for the ‘Content editor web part’ Category


Just add this style in a content editor web part in the page you want to hide your left navigation. In case you need to hide it in all the pages, add this to your master page.

<style type=”text/css”>
body #s4-leftpanel { display: none; }
.s4-ca { margin-left: 0px; }
</style>

The style applied to body #s4-leftpanel hides the left navigation & the style applied to .s4-ca removes the empty space & moves the other content of the page towards the left side.

 

Advertisements

The below code adds and displays a timer in your page. Just add this script to your content editor webpart. Time will be displayed in format MM:SS

To change the time set the variable start in seconds. In the two if loops, 1st one is used to display a message when a particular time is reached, 2nd is used to closed the window when the time is over. You can also add custom actions by validating the current time using the variable seconds.

<div id=”countdown”></div>
<div id=”notifier”></div>

<script type=”text/javascript”>

var start = 600;
Number.prototype.toMinutesAndSeconds = function()
{
    var nbr = Math.floor(this / 60);
    return (nbr+”:”)+(((nbr=(this-(nbr*60)))<10)?”0″+nbr:nbr);
}

function display(seconds, output)
{
    output.innerHTML = “<b><font size=’3′>Time left for you to submit the form </font></b><font size=’5′ color=’Green’>” + (–seconds).toMinutesAndSeconds()     + “</font>”;

    if(seconds > 0)
    {
            window.setTimeout(function(){display(seconds, output)}, 1000);
    }

    if(seconds < 121)
    {
            document.getElementById(“notifier”).innerHTML = “&nbsp;<font size=’2′ color=’Red’>Less than 2 minutes  available. Please submit the form.”;
    }

    if (seconds == 1)
    {
        window.alert(‘Sorry!! Time is over.’);
        window.open(”, ‘_self’, ”);
        window.close();
    }
}

display(start, document.getElementById(“countdown”));

</script>


Normally when we create a SharePoint List before adding any new item you will find a default text stating no item is there. For example in announcements list you may find


There are no items to show in this view of the “Announcements” list. To create a new item, click “New” above.

That’s great. But what if the user is not having permission to create a new item or if you have removed the toolbar of the web part. Or think you have displayed an Announcement web part in your home page, asking the visitor to create a new announcement.

To change this default text displayed use the script below

<script>
function ChangeNewMessage()
{

var a = document.getElementsByTagName(“TD”)
for (var i=0;i<a.length;i++)
{
if (a[i].className==”ms-vb”)
{
if (a[i].innerText.indexOf(“
There are no items to show in this view of the “Announcements” list. “)>-1)
{
a[i].innerHTML = “Coming Soon..”;
}
}
}
}

_spBodyOnLoadFunctionNames.push(“ChangeNewMessage”)
</script>


You just want to change the “There are no items to show in this view of ” text for different lists.