Greetings all,
I assume this is the correct forum for this because it only happens on the client size. The page is written in XHTML ASP/VB.net 2.0, but I don't think that is the forum for this question.
The problem only happens in IE 7 (possibly 6 and 8, but I don't care about those browsers as the environment will be strictly IE7). Firefox has no problems. This is an intranet website. The problem also only happens when the javascript is in an external file and not when the code is pasted into the aspx file directly.
I have the following JS code:
Again, when pasted directly into the aspx file, no errors and everyone is fat dumb and very happy. When referenced:
I get the ever-popular "syntax error" referencing the very last character of the .js file.
Any ideas as to why this is? I do appreciate the help.
"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws
I assume this is the correct forum for this because it only happens on the client size. The page is written in XHTML ASP/VB.net 2.0, but I don't think that is the forum for this question.
The problem only happens in IE 7 (possibly 6 and 8, but I don't care about those browsers as the environment will be strictly IE7). Firefox has no problems. This is an intranet website. The problem also only happens when the javascript is in an external file and not when the code is pasted into the aspx file directly.
I have the following JS code:
Code:
var mon = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var month = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var current_date = new Date();
var cal_date = new Date();
var selected_month = cal_date.getMonth();
cal_date.setDate(1);
var toggle_fld;
var mouseX, mouseY;
if(document.getElementById('sm_cal')) create_small_calendar(0);
document.onmousemove = getXY;
function getXY(e) {
if(document.all) {
mouseX = window.event.clientX + document.documentElement.scrollLeft;
mouseY = window.event.clientY + document.documentElement.scrollTop;
} else {
mouseX = e.pageX;
mouseY = e.pageY;
}
}
function create_small_calendar(act) {
cal_date.setMonth(cal_date.getMonth() + act);
selected_month = cal_date.getMonth();
if(selected_month == 12) selected_month = 0;
document.getElementById('sm_cal_title').innerHTML = mon[cal_date.getMonth()] + ' ' + cal_date.getFullYear();
document.getElementById('sm_cal_content').innerHTML = "";
//set the date to the sunday prior to the first and print out the rest of the current month
cal_date.setDate(1);
cal_date.setDate((0 - cal_date.getDay()+1));
while(cal_date.getMonth() == (selected_month)-1 || cal_date.getMonth() == (selected_month) || (cal_date.getMonth() == 11 && selected_month == 0)) { //starts at 11 which is greater than 1
var day_box = "<div ";
day_box += " onclick='select_date(this);'";
if(cal_date.getMonth() != selected_month) day_box += " class='day othermonth'";
else day_box += " class='day'";
day_box += "id='"+cal_date.getMonth() + "-" + cal_date.getDate() + "-" + cal_date.getFullYear()+"'>";
day_box += cal_date.getDate() + " ";
day_box += "</div>";
document.getElementById('sm_cal_content').innerHTML += day_box;
cal_date.setDate(cal_date.getDate() + 1);
}
//finish printing the last week
while(cal_date.getDay() != 0) {
var day_box = "<div ";
day_box += " onclick='select_date(this);'";
if(cal_date.getMonth() != selected_month) day_box += " class='day othermonth'";
else day_box += " class='day'";
day_box += "id='"+cal_date.getMonth() + "-" + cal_date.getDate() + "-" + cal_date.getFullYear()+"'>";
day_box += cal_date.getDate() + " ";
day_box += "</div>";
document.getElementById('sm_cal_content').innerHTML += day_box;
cal_date.setDate(cal_date.getDate() + 1);
}
}
function toggle_sm_cal(fld) {
toggle_fld = fld;
document.getElementById('sm_cal').style.left = mouseX + 10 + 'px';
document.getElementById('sm_cal').style.top = mouseY + 10 + 'px';
if(document.getElementById('sm_cal').style.display == 'none') {
document.getElementById('sm_cal').style.display = 'block';
} else {
document.getElementById('sm_cal').style.display = 'none';
cal_date.setTime(current_date.getTime());
create_small_calendar(0);
}
}
function select_date(dte) {
var temp = dte.id.split('-');
document.getElementById(toggle_fld).value = (parseInt(temp[0],10)+1) + '-' + temp[1] + '-' + temp[2];
toggle_sm_cal();
}
Again, when pasted directly into the aspx file, no errors and everyone is fat dumb and very happy. When referenced:
Code:
<script type="text/javascript" src="/modules/calendar.js"></script>
Any ideas as to why this is? I do appreciate the help.
"If it's stupid but works, it isn't stupid."
-Murphy's Military Laws