Mam problem z kodem javascript na stronie
http://www.komplex.cc/.
Strona nie działa w IE. FF nie zwraca żadnych błędów.
Kod
<script type="text/javascript"> var xmlhttp;
var old_x;
var old_y;
var w = 0, h = 0;
function getwh(){
//alert("jgjg");
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
w = window.innerWidth;
h = window.innerHeight;
}
else{
window.location = "./ie.html"
}
}
function display_info(i,u,x,y,t,l,c){
display_infoimg("");
info = document.getElementById("info");
rect = document.getElementById("rect");
if(u=="" || (old_x==x && old_y==y)){
info.innerHTML = '';
rect.style.width = '0px';
rect.style.height = '0px';
old_x = x;
old_y = y;
}
else{
info.style.zindex = '50';
if(i==""){infostring = '
<b>'+ u + '
</b>';}
else{
infostring = '
<b>'+ u + '
</b><br><i>' + i + '
</i>';}
info.innerHTML = infostring;
rect.style.position = 'fixed';
rect.style.left = l + 1 + 'px';
rect.style.top = t + 1 + 'px';
rect.style.backgroundColor = '#' + c ;
rect.style.zindex = '25';
rect.style.width = '599px';
rect.style.height = '599px';
if( rect.attachEvent ){
rect.attachEvent('onclick', 'cell('+ x + ',' + y + ')');
} else {
rect.setAttribute('onclick', 'cell('+ x + ',' + y + ')');
}
old_x = x;
old_y = y;
}
}
function display_infomap(i,u){
info = document.getElementById("info");
if(u=="" && i==""){
info.innerHTML = '';
}
else{
info.style.zindex = '50';
if(i==""){
infostring = '
<b>'+ u + '
</b>';}
else{
infostring = '
<b>'+ u + '
</b><br><i>' + i + '
</i>';}
info.innerHTML = infostring;
}
}
function display_infoimg(i, x){
//hide_info();
infoimg = document.getElementById("infoimg");
infoimg.style.zindex = '100';
infoimg.innerHTML = i;
if(x==1){
info = document.getElementById("info").innerHTML = "";
infoimg.style.color = '#ff0000';
}
else {
infoimg.style.color = '#333333';
}
}
function hide_info(){
//////////////////
rect = document.getElementById("rect");
info = document.getElementById("info");
info.innerHTML = '';
rect.style.width = '0px';
rect.style.height = '0px';
rect.style.position = 'fixed';
rect.style.left = '-1px';
rect.style.top = '-1px';
old_x = 0;
old_y=0;
}
function wind_scroll(x,y){
window.scroll(x,y);
}
function logout(){
var url="login.php?f=logout";
url+="&w="+w;
url+="&h="+h;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function login(){
var url="login.php";
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function add_user(x,y){
display_infoimg("");
l1 = document.getElementById("l1").value;
l2 = document.getElementById("l2").value;
l3 = document.getElementById("l3").value;
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="cell.php";
url+="?x="+x;
url+="&y="+y;
url+="&w="+w;
url+="&h="+h;
url+="&f=add_user";
url+="&username="+l1;
url+="&password="+l2;
url+="&color="+l3;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function add_user_form(x,y){
display_infoimg("");
hide_info();
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="cell.php";
url+="?x="+x;
url+="&y="+y;
url+="&w="+w;
url+="&h="+h;
url+="&f=add_user_form";
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function add_content1(x,y){
display_infoimg("");
l1 = document.getElementById("content_type").value;
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="cell.php";
url+="?x="+x;
url+="&y="+y;
url+="&w="+w;
url+="&h="+h;
url+="&f=add_content1";
url+="&type="+l1;
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function edit1(x,y)
{
display_infoimg("");
hide_info();
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="cell.php";
url+="?x="+x;
url+="&y="+y;
url+="&w="+w;
url+="&h="+h;
url+="&f=edit1";
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function delcell(x,y)
{
display_infoimg("");
hide_info();
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="cell.php";
url+="?x="+x;
url+="&y="+y;
url+="&w="+w;
url+="&h="+h;
url+="&f=delcell";
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function cell(x,y)
{
display_infoimg("");
getwh();
hide_info();
//alert(x + ' ' + y);
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="cell.php";
url+="?x="+x;
url+="&y="+y;
url+="&w="+w;
url+="&h="+h;
url+="&f=closeup";
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function map()
{
getwh();
hide_info();
display_infoimg(' ');
//alert(x + y);
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Browser does not support HTTP Request");
return;
}
var url="cell.php";
url+="?x=0";
url+="&y=0";
url+="&w="+w;
url+="&h="+h;
url+="&f=map";
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
document.getElementById('main').innerHTML=xmlhttp.responseText;
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
//alert("huj");
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
i
<script type="text/javascript"> <!--
//document.addEventListener('mousemove', skinableCursor.move, false);
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false
// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
// Temporary variables to hold mouse x-y pos.s
var tempX = 0
var tempY = 0
// Main function to retrieve mouse x-y pos.s
function getMouseXY(e) {
if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft
tempY = event.clientY + document.body.scrollTop
} else { // grab the x-y pos.s if browser is NS
tempX = e.pageX
tempY = e.pageY
}
// catch possible negative values in NS4
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}
// show the position values in the form named Show
// in the text fields named MouseX and MouseY
var w,h = 0;
if( typeof( window.innerWidth ) == 'number' ) {
//Non-IE
w = window.innerWidth;
h = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
w = document.documentElement.clientWidth;
h = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
//IE 4 compatible
w = document.body.clientWidth;
h = document.body.clientHeight;
}
document.getElementById("info").style.position = 'absolute';
document.getElementById("infoimg").style.position = 'absolute';
var off_x, off_y =0;
if(tempX<w/2){off_x = 10;} else {off_x = -80;}
if(tempY<h/2){off_y = 10;} else {off_y = -80;}
document.getElementById("info").style.left = tempX + off_x;
document.getElementById("info").style.top = tempY + off_y;
document.getElementById("infoimg").style.left = tempX + 10;
document.getElementById("infoimg").style.top = tempY + 10;
return true
}
</script>
wydaje mi się że zawodzi ActiveXObject, sprawdze to jeszcze.
Edit: Zawodzi funkcja display_infomap
Pozdrawiam
Ten post edytował Lejto 4.07.2009, 17:17:07