duckboxxer
Junior Member
Posts: 2
Registered: 9/12/2003
Member Is Offline
|
| posted on 9/12/2003 at 09:27 PM |
|
|
Files in directory above
My calendar files are in the directory above where the calling file is located. I've monkeyed with the code a little to get the files to show up
correctly on load, but if you click to change the month or year, the page is not found. Now for some reason, this works fine in IE, but NS (any
version) and Opera 7 have problems with this. Below is my code, please point out any deficiences. Thanks.
function cal_popup1 (str_datetime) {
this.dt_current = this.prs_tsmp(str_datetime ? str_datetime : this.target.value);
if (!this.dt_current) return;
// MCG added code below to deal with sub directories
currentDir = document.URL;
// remove siteRoot
currentDir = currentDir.replace(siteRoot, "");
//remove filename
slashLocation = currentDir.lastIndexOf("/");
currentDir = currentDir.slice(0, slashLocation + 1);
// replace directories with '..'
if (currentDir.length != 0)
currentDir = currentDir.replace(/[A-Za-z0-9_\-]+/g, "..");
var obj_calwindow = window.open(currentDir + 'calendar.html?datetime=' + this.dt_current.valueOf()+ '&id=' + this.id,
'Calendar', 'width=200,height='+(this.time_comp ? 215 : 190)+
',status=no,resizable=no,top=200,left=200,dependent=yes,alwaysRaised=yes');
obj_calwindow.opener = window;
obj_calwindow.focus();
}
|
|
|
nik
Posts:
Registered: 1/1/1970
Member Is Offline
|
| posted on 9/16/2003 at 01:12 PM |
|
|
The problem happens because IE and Netscape work with relative paths in different ways: for IE the counting point is always a directory where working
JS codes are linked, for Netscape - a point of last JS codes call. In given case calendar. html file is located in one-leveled-up than index.html
file. Your code defines level to load calendar. html by popup mode call and adds it to calendar. html in call while creating new window. But while
shifting months and years the same popup mode is called but now from
calendar. html page. That's why for Netscape by adding output level non-existent path is received.
To solve this problem you should define browser type and point from which popup mode is called.
Regarding these data we add or don't add a level.
function cal_popup1 (str_datetime,pointincom) {
siteRoot = 'http://localhost/troble/troble10_us/';
currentDir = '';
var b = navigator.appName;
this.dt_current = this.prs_tsmp(str_datetime ? str_datetime : this.target.value);
if (!this.dt_current) return;
if (pointincom != null || b == "Microsoft Internet Explorer") {
// MCG added code below to deal with sub directories
currentDir = document.URL;
// remove siteRoot
currentDir = currentDir.replace(siteRoot, "");
//remove filename
slashLocation = currentDir.lastIndexOf("/");
currentDir = currentDir.slice(0, slashLocation + 1);
// replace directories with '..'
if (currentDir.length != 0)
currentDir = currentDir.replace(/[A-Za-z0-9_\-]+/g, "..");
}
var obj_calwindow = window.open(
currentDir + 'calendar.html?datetime=' + this.dt_current.valueOf()+ '&id=' + this.id,
'Calendar', 'width=200,height='+(this.time_comp ? 215 : 190)+
',status=1,resizable=1,location=1,top=200,left=200,dependent=yes,alwaysRaised=yes'
);
obj_calwindow.opener = window;
obj_calwindow.focus();
}
We add new pointincom parameter that defines input point.
If null (not defined) then it is from index.html;
if parameter is defined then from calendar. html.
As input parameters of cal_popup1 function have changed calendar call from index.html page has also changed.
<a href="javascript:cal1.popup(null,true);">
where the first parameter is the same but required for pointing and the second defines input point.
|
|
|
duckboxxer
Junior Member
Posts: 2
Registered: 9/12/2003
Member Is Offline
|
| posted on 9/16/2003 at 01:29 PM |
|
|
Found an answer
I figured out that IE & NS/Opera treat things differently. Actually I found an answer. I just check to see if str_datetime is null or not. If
it is, put in the '../' part of things. Otherwise, just leave it empty. Thanks!
mcg
|
|
|
|