Friday, March 30, 2012

Alert pop up windows in SharePoint site

I found following JavaScript (obviously on internet, I am not a core developer) and placed it in CEWP on above mentioned site. In fact I did little changes in code to get required pop up with message and to display it once when page load first time in new window.

<script language='JavaScript'>
var alertmessage="This is the test popup"
//Alert only once per browser session (0=no, 1=yes)
var once_per_session=0
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { // if cookie exists
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
return returnvalue;
function alertornot(){
if (get_cookie('alerted')==''){
function loadalert(){
if (once_per_session==0)
To display a particular message on the popup we have to replaced “This is the test popup” lines highlighted in script, and to change popup display per session we have to change variable to “0” or “1” (please refer highlighted “var once_per_session=0”)

Popular Posts


The opinions expressed on this blog are the personal views of Pratik's SharePoint Blog, and do not represent or reflect the viewpoints or policies of any past, present, or future employer, colleague, or customer, or any other entity. The posts on this blog are provided ‘as is’ with no warranties, express or implied, and confer no rights. Use of information contained within this blog, including specific technical steps mentioned herein, is at your own risk. References to specific software products, processes, resources, or companies do not imply any endorsement.