MOSS 2007 ConfirmBox

Today I have struggled for many hours, to insert a confirmbox in sharepoint when editors want to remove a webpart. OOTB there is no time to regret clicking the "remove" icon. Now there is :-) Insert the below code and run "addConfirmToRemove()" onload:


function addConfirmToRemove() {
    if (IsInDesignMode()) {
        var links = document.getElementsByTagName('A');
        for (var i = 0; i < links.length; i++) {
            if (links[i].onclick) {
                var onclick = links[i].onclick + "";
                var index = onclick.indexOf("MSOLayout_RemoveWebPart");
                if (index > 0) {
                     links[i].onclick = function() {if(confirm('Press OK to remove the webpart')) {MSOLayout_RemoveWebPart(document.all[this.id.replace('_Close','')])}};
                }
            }
        }
    }
}

function IsInDesignMode()
{
   if(document.getElementById("MSOLayout_InDesignMode").value == "1") return true;
   if(document.getElementById("MSOTlPn_SelectedWpId").value != "") return true;
   return false;
}

 

Sidst opdateret: 16. dec.  2016

Submenu