Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Broken Pop-up Window

Status
Not open for further replies.

ASCII

Programmer
Mar 6, 2002
3
0
0
US
I have a pop-up window in javascript that when it opens on top of the textbox, the windows has holes or broken. How can I fix this? My client browser is NN 4.7 .
 
Can you post the code or the URL??
Is the pop-up created via layers?? This doesn't happen in IE right?? I have not failed; I merely found 100,000 different ways of not succeding...
 
var ppcDF = "m/d/Y";
var ppcMN = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var ppcWN = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var ppcER = new Array(4);
ppcER[0] = "Required DHTML functions are not supported in this browser.";
ppcER[1] = "Target form field is not assigned or not accessible.";
ppcER[2] = "Sorry, the chosen date is not acceptable. Please read instructions on the page.";
ppcER[3] = "Unknown error occured while executing this script.";
var ppcUC = false;
var ppcUX = 4;
var ppcUY = 4;

/* Do not edit below this line unless you are sure what are you doing! */

var ppcIE=(navigator.appName == "Microsoft Internet Explorer");
var ppcNN=((navigator.appName == "Netscape")&&(document.layers));
var ppcTT=&quot;<table width=\&quot;200\&quot; cellspacing=\&quot;1\&quot; cellpadding=\&quot;2\&quot; border=\&quot;1\&quot; bordercolorlight=\&quot;#000000\&quot; bordercolordark=\&quot;#000000\&quot;>\n&quot;;
var ppcCD=ppcTT;var ppcFT=&quot;<font face=\&quot;MS Sans Serif, sans-serif\&quot; size=\&quot;1\&quot; color=\&quot;#000000\&quot;>&quot;;var ppcFC=true;
var ppcTI=false;var ppcSV=null;var ppcRL=null;var ppcXC=null;var ppcYC=null;
var ppcML=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var ppcWE=new Array(&quot;Sunday&quot;,&quot;Monday&quot;,&quot;Tuesday&quot;,&quot;Wednesday&quot;,&quot;Thursday&quot;,&quot;Friday&quot;,&quot;Saturday&quot;);
var ppcNow=new Date();var ppcPtr=new Date();
if (ppcNN) {
window.captureEvents(Event.RESIZE);
window.onresize = restoreLayers;
document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
document.onmousedown = recordXY;
document.onmouseup = confirmXY;}
function restoreLayers(e) {
if (ppcNN) {
with (window.document) {
open(&quot;text/html&quot;);
write(&quot;<html><head><title>Restoring the layer structure...</title></head>&quot;);
write(&quot;<body bgcolor=\&quot;#FFFFFF\&quot; onLoad=\&quot;history.go(-1)\&quot;>&quot;);
write(&quot;</body></html>&quot;);
close();}}}
function recordXY(e) {
if (ppcNN) {
ppcXC = e.x;
ppcYC = e.y;
document.routeEvent(e);}}
function confirmXY(e) {
if (ppcNN) {
ppcXC = (ppcXC == e.x) ? e.x : null;
ppcYC = (ppcYC == e.y) ? e.y : null;
document.routeEvent(e);}}
function getCalendarFor(target,rules) {
ppcSV = target;
ppcRL = rules;
if (ppcFC) {setCalendar();ppcFC = false;}
if ((ppcSV != null)&&(ppcSV)) {
if (ppcIE) {
var obj = document.all['PopUpCalendar'];
obj.style.left = document.body.scrollLeft+event.clientX;
obj.style.top = document.body.scrollTop+event.clientY;
obj.style.visibility = &quot;visible&quot;;}
else if (ppcNN) {
var obj = document.layers['PopUpCalendar'];
obj.left = ppcXC
obj.top = ppcYC
obj.visibility = &quot;show&quot;;}
else {showError(ppcER[0]);}}
else {showError(ppcER[1]);}}
function switchMonth(param) {
var tmp = param.split(&quot;|&quot;);
setCalendar(tmp[0],tmp[1]);}
function moveMonth(dir) {
var obj = null;
var limit = false;
var tmp,dptrYear,dptrMonth;
if (ppcIE) {obj = document.ppcMonthList.sItem;}
else if (ppcNN) {obj = document.layers['PopUpCalendar'].document.layers['monthSelector'].document.ppcMonthList.sItem;}
else {showError(ppcER[0]);}
if (obj != null) {
if ((dir.toLowerCase() == &quot;back&quot;)&&(obj.selectedIndex > 0)) {obj.selectedIndex--;}
else if ((dir.toLowerCase() == &quot;forward&quot;)&&(obj.selectedIndex < 12)) {obj.selectedIndex++;}
else {limit = true;}}
if (!limit) {
tmp = obj.options[obj.selectedIndex].value.split(&quot;|&quot;);
dptrYear = tmp[0];
dptrMonth = tmp[1];
setCalendar(dptrYear,dptrMonth);}
else {
if (ppcIE) {
obj.style.backgroundColor = &quot;#FF0000&quot;;
window.setTimeout(&quot;document.ppcMonthList.sItem.style.backgroundColor = '#FFFFFF'&quot;,50);}}}
function selectDate(param) {
var arr = param.split(&quot;|&quot;);
var year = arr[0];
var month = arr[1];
var date = arr[2];
var ptr = parseInt(date);
ppcPtr.setDate(ptr);
if ((ppcSV != null)&&(ppcSV)) {
if (validDate(date)) {ppcSV.value = dateFormat(year,month,date);hideCalendar();}
else {showError(ppcER[2]);if (ppcTI) {clearTimeout(ppcTI);ppcTI = false;}}}
else {
showError(ppcER[1]);
hideCalendar();}}
function setCalendar(year,month) {
if (year == null) {year = getFullYear(ppcNow);}
if (month == null) {month = ppcNow.getMonth();setSelectList(year,month);}
if (month == 1) {ppcML[1] = (isLeap(year)) ? 29 : 28;}
ppcPtr.setYear(year);
ppcPtr.setMonth(month);
ppcPtr.setDate(1);
updateContent();}
function updateContent() {
generateContent();
if (ppcIE) {document.all['monthDays'].innerHTML = ppcCD;}
else if (ppcNN) {
with (document.layers['PopUpCalendar'].document.layers['monthDays'].document) {
open(&quot;text/html&quot;);
write(&quot;<html>\n<head>\n<title>DynDoc</title>\n</head>\n<body bgcolor=\&quot;#FFFFFF\&quot;>\n&quot;);
write(ppcCD);
write(&quot;</body>\n</html>&quot;);
close();}}
else {showError(ppcER[0]);}
ppcCD = ppcTT;}
function generateContent() {
var year = getFullYear(ppcPtr);
var month = ppcPtr.getMonth();
var date = 1;
var day = ppcPtr.getDay();
var len = ppcML[month];
var bgr,cnt,tmp = &quot;&quot;;
var j,i = 0;
for (j = 0; j < 7; ++j) {
if (date > len) {break;}
for (i = 0; i < 7; ++i) {
bgr = ((i == 0)||(i == 6)) ? &quot;#FFFFCC&quot; : &quot;#FFFFFF&quot;;
if (((j == 0)&&(i < day))||(date > len)) {tmp += makeCell(bgr,year,month,0);}
else {tmp += makeCell(bgr,year,month,date);++date;}}
ppcCD += &quot;<tr align=\&quot;center\&quot;>\n&quot; + tmp + &quot;</tr>\n&quot;;tmp = &quot;&quot;;}
ppcCD += &quot;</table>\n&quot;;}
function makeCell(bgr,year,month,date) {
var param = &quot;\'&quot;+year+&quot;|&quot;+month+&quot;|&quot;+date+&quot;\'&quot;;
var td1 = &quot;<td width=\&quot;20\&quot; bgcolor=\&quot;&quot;+bgr+&quot;\&quot; &quot;;
var td2 = (ppcIE) ? &quot;</font></span></td>\n&quot; : &quot;</font></a></td>\n&quot;;
var evt = &quot;onMouseOver=\&quot;this.style.backgroundColor=\'#FF0000\'\&quot; onMouseOut=\&quot;this.style.backgroundColor=\'&quot;+bgr+&quot;\'\&quot; onMouseUp=\&quot;selectDate(&quot;+param+&quot;)\&quot; &quot;;
var ext = &quot;<span Style=\&quot;cursor: hand\&quot;>&quot;;
var lck = &quot;<span Style=\&quot;cursor: default\&quot;>&quot;;
var lnk = &quot;<a href=\&quot;javascript:selectDate(&quot;+param+&quot;)\&quot; onMouseOver=\&quot;window.status=\' \';return true;\&quot;>&quot;;
var cellValue = (date != 0) ? date+&quot;&quot; : &quot;&nbsp;&quot;;
if ((ppcNow.getDate() == date)&&(ppcNow.getMonth() == month)&&(getFullYear(ppcNow) == year)) {
cellValue = &quot;<b><font color=red>&quot; + cellValue + &quot;</font></b>&quot;;} //higlight today
var cellCode = &quot;&quot;;
if (date == 0) {
if (ppcIE) {cellCode = td1+&quot;Style=\&quot;cursor: default\&quot;>&quot;+lck+ppcFT+cellValue+td2;}
else {cellCode = td1+&quot;>&quot;+ppcFT+cellValue+td2;}}
else {
if (ppcIE) {cellCode = td1+evt+&quot;Style=\&quot;cursor: hand\&quot;>&quot;+ext+ppcFT+cellValue+td2;}
else {
if (date < 10) {cellValue = &quot;&nbsp;&quot; + cellValue + &quot;&nbsp;&quot;;}
cellCode = td1+&quot;>&quot;+lnk+ppcFT+cellValue+td2;}}
return cellCode;}
function setSelectList(year,month) {
var i = 0;
var obj = null;
if (ppcIE) {obj = document.ppcMonthList.sItem;}
else if (ppcNN) {obj = document.layers['PopUpCalendar'].document.layers['monthSelector'].document.ppcMonthList.sItem;}
else {/* NOP */}
while (i < 13) {
obj.options.value = year + &quot;|&quot; + month;
obj.options.text = year + &quot; • &quot; + ppcMN[month];
i++;
month++;
if (month == 12) {year++;month = 0;}}}
function hideCalendar() {
if (ppcIE) {document.all['PopUpCalendar'].style.visibility = &quot;hidden&quot;;}
else if (ppcNN) {document.layers['PopUpCalendar'].visibility = &quot;hide&quot;;window.status = &quot; &quot;;}
else {/* NOP */}
ppcTI = false;
setCalendar();
ppcSV = null;
if (ppcIE) {var obj = document.ppcMonthList.sItem;}
else if (ppcNN) {var obj = document.layers['PopUpCalendar'].document.layers['monthSelector'].document.ppcMonthList.sItem;}
else {/* NOP */}
obj.selectedIndex = 0;}
function showError(message) {
window.alert(&quot;[ PopUp Calendar ]\n\n&quot; + message);}
function isLeap(year) {
if ((year%400==0)||((year%4==0)&&(year%100!=0))) {return true;}
else {return false;}}
function getFullYear(obj) {
if (ppcNN) {return obj.getYear() + 1900;}
else {return obj.getYear();}}
function validDate(date) {
var reply = true;
if (ppcRL == null) {/* NOP */}
else {
var arr = ppcRL.split(&quot;:&quot;);
var mode = arr[0];
var arg = arr[1];
var key = arr[2].charAt(0).toLowerCase();
if (key != &quot;d&quot;) {
var day = ppcPtr.getDay();
var orn = isEvenOrOdd(date);
reply = (mode == &quot;[^]&quot;) ? !((day == arg)&&((orn == key)||(key == &quot;a&quot;))) : ((day == arg)&&((orn == key)||(key == &quot;a&quot;)));}
else {reply = (mode == &quot;[^]&quot;) ? (date != arg) : (date == arg);}}
return reply;}
function isEvenOrOdd(date) {
if (date - 21 > 0) {return &quot;e&quot;;}
else if (date - 14 > 0) {return &quot;o&quot;;}
else if (date - 7 > 0) {return &quot;e&quot;;}
else {return &quot;o&quot;;}}
function dateFormat(year,month,date) {
if (ppcDF == null) {ppcDF = &quot;m/d/Y&quot;;}
var day = ppcPtr.getDay();
var crt = &quot;&quot;;
var str = &quot;&quot;;
var chars = ppcDF.length;
for (var i = 0; i < chars; ++i) {
crt = ppcDF.charAt(i);
switch (crt) {
case &quot;M&quot;: str += ppcMN[month]; break;
case &quot;m&quot;: str += (month<9) ? (&quot;0&quot;+(++month)) : ++month; break;
case &quot;Y&quot;: str += year; break;
case &quot;y&quot;: str += year.substring(2); break;
case &quot;d&quot;: str += ((ppcDF.indexOf(&quot;m&quot;)!=-1)&&(date<10)) ? (&quot;0&quot;+date) : date; break;
case &quot;W&quot;: str += ppcWN[day]; break;
default: str += crt;}}
return unescape(str);}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top