I am having errors with the redirect. It is taking me to the following page www.home.com/SITE1/undefined
I am implementing cookies and I think this might be the problem. The reason for the cookie is that I do not want the user to be prompted when they click back. The modal serves as a quick path to commonly used webpages. So I am going to include my complete code. I utilized 90% of this modal with the cookie function. I only wanted to modified it to include 3 more buttons.
Modal.aspx (page rendered inside the modal)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<meta name="WebPartPageExpansion" content="full" />
<style type="text/css">
ul,ol {text-align: left;}
li {list-style-type: circle; padding-top: 15px;}
.subcontent {width: 500px; margin: 0 auto;}
.domainName {color: Navy; font-weight: bold;}
</style>
<script type="text/javascript">
function closePage(redirectURL) {
createCookie("Test", "ACCEPTED");
SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.OK, redirectURL);
}
function createCookie(name, value) {
var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
</script>
</head>
<body style="text-align: center;">
<form name="form1" method="post" action="Modal.aspx?IsDlg=1" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wPDwUKLTcxMDYyNDk4OA9kFgICBA9kFgICAQ8WAh4HVmlzaWJsZWdkZJ+th6rM5boAX+jz8z6RusiKXoWY" />
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgK83aGICgKUxcvrDpIDY1zrMzRi62kcWf2pzau3Dch0" />
</div>
<div id="ExSection">
</div>
<input type="submit" name="btn1" value="SITE 1" onclick="closePage('www.home.com/SITE1');" id="btn1" />
<input type="submit" name="btn2" value="SITE 2" onclick="closePage('www.home.com/SITE2');" id="btn2" />
<input type="submit" name="btn3" value="SITE 3" onclick="closePage('www.home.com/SITE3');" id="btn3" />
</div>
</form>
The CEWP on the parent page
<script type="text/javascript">
function LoadDialog () {
SP.UI.ModalDialog.showModalDialog({
title: "TEST MODAL BOX",
url: "www.home.com/Modal.aspx",
width: 800,
heigth: 600,
dialogReturnValueCallback: dialogCallback
});
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function LoadDialogWrapper() {
var x = readCookie('Test');
if (!x) {
setTimeout("LoadDialog()", 1000);
}
}
function dialogCallback(dialogResult, returnValue) {
if(dialogResult== SP.UI.DialogResult.OK)
{
window.location.href = returnValue;
}
}
_spBodyOnLoadFunctionNames.push("LoadDialogWrapper");
</script>