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”)

No comments: