Jump to content


JavaScript - Not Working in IE


1 reply to this topic

#1 FlawedKid

    Young Padawan

  • Members
  • Pip
  • 36 posts

Posted 02 May 2006 - 01:30 PM

I working on a site re-design and I have run into some trouble when I tested the site in IE.
Please take a look at the site:
HERES THE SITE

I generaly use Mozilla and the floating Div displays fine. I will past the code but you can may also want to do a View Page Source.

I have given the Div and ID name of "FloatLayer" which is refered to in the JS. Just incase your wondering.

Ok so heres the JS code place below my Menu/DIV

<script language="JavaScript" type="text/JavaScript">
var hX = 'centre';
var vY = 291;
var nn=(navigator.appName.indexOf("Netscape")!=-1);
var dD=document,dH=dD.html,dB=dD.body,px=dD.layers?'':'px';

function floatLayer(iX,iY,id){
var L=dD.getElementById?dD.getElementById(id):dD.all?dD.all[id]:dD.layers[id];
this[id+'O']=L;
if(dD.layers)L.style=L;
L.nX=L.iX=iX;
L.nY=L.iY=iY;

L.P=function(x,y){
this.style.left=x+px;
this.style.top=y+px;
}
L.Fm=function(){
var pX, pY;
pX=(this.iX >=0)?0:nn?innerWidth:nn&&dH.clientWidth?dH.clientWidth:dB.clientWidth;
pY=nn?pageYOffset:nn&&dH.scrollTop?dH.scrollTop:dB.scrollTop;
if(this.iY<0)pY+=nn?innerHeight:nn&&dH.clientHeight?dH.clientHeight:dB.clientHeight;
this.nX+=.1*(pX+this.iX-this.nX);
this.nY+=.1*(pY+this.iY-this.nY);
this.P(this.nX,this.nY);
setTimeout(this.id+'O.Fm()',33);
}
return L;
}
floatLayer(hX,vY,'FloatLayer').Fm();
</script>

I would really appreciate some help with this ASAP! as its an urgent matter for me.

Biggest thanks in advance EVER :)

====================

I just received some advice and that was to replace the code

]L.P=function(x,y){
this.style.left=x+px;
this.style.top=y+px;
}

With...

L.P=function(x,y){
	try {
		this.style.left=x+px;
		this.style.top=y+px;
	} catch(e) {
		this.style.pixelLeft=x+'px';
		this.style.pixelTop=y+'px';
	}
}

But unfortunately this did not help :) what this did was position the DIV/Menu in the top left hand corner and was still un-scrollable/floating when viewing in IE. But again showd fine in Mozilla?

Just thort the above ^^ would be worth mentioning and maybe lead someone in the direction to solving my problem. :wacko:


=======================

Any JavaScript experts that can help? Surely

posts merged

Edited by Donna, 02 May 2006 - 06:10 PM.


#2 Futingkiller

    Young Padawan

  • Members
  • Pip
  • 110 posts

Posted 03 May 2006 - 09:25 AM

i have some script that makes 4 Divs folow a circle ecuation
here it is:

<html>
<head>
<title>
Move
</title>
</head>
<body vlink='#FFFFFF' alink="#FFFFFF" link="#FFFFFF">
<script type="text/javascript">
var t=new Array(0,25,50,75);
var a;
document.write("<div id='I0' style='position:absolute'><a target='Base' href='Snake/Snake.php' onclick='f();a=0;'>");
document.write("<img name='pic' src='Snake.gif' width='85' height='20'></a></div>");
document.write("<div id='I1' style='position:absolute'><a onclick='f();a=1;'>");
document.write("<img name='pic' src='Home.gif' width='85' height='20'></a></div>");
document.write("<div id='I2' style='position:absolute'><a onclick='f();a=2;'>");
document.write("<img name='pic' src='Contact.gif' width='85' height='20'></a></div>");
document.write("<div id='I3' style='position:absolute'><a href='Whack%20the%20pinguin/Whack_the_pinguin.html' target='Base' onclick='f();a=3;'>");
document.write("<img name='pic' src='Whack.gif' width='85' height='20'></a></div>");
document.getElementById('I0').style.left=70+60*Math.sin(2*Math.PI*t[0]/100);
document.getElementById('I0').style.top=70+60*Math.cos(2*Math.PI*t[0]/100);
document.getElementById('I1').style.left =70+60*Math.sin(2*Math.PI*t[1]/100);
document.getElementById('I1').style.top =70+60*Math.cos(2*Math.PI*t[1]/100);
document.getElementById('I2').style.left =70+60*Math.sin(2*Math.PI*t[2]/100);
document.getElementById('I2').style.top =70+60*Math.cos(2*Math.PI*t[2]/100);
document.getElementById('I3').style.left =70+60*Math.sin(2*Math.PI*t[3]/100);
document.getElementById('I3').style.top =70+60*Math.cos(2*Math.PI*t[3]/100);
function f()
{
t[0]=(t[0]+1)%100;
t[1]=(t[1]+1)%100;
t[2]=(t[2]+1)%100;
t[3]=(t[3]+1)%100;
if(t[a]!=50){
x=setTimeout("f();",7);}
document.getElementById('I0').style.left=70+60*Math.sin(2*Math.PI*t[0]/100);
document.getElementById('I0').style.top=70+60*Math.cos(2*Math.PI*t[0]/100);
document.getElementById('I1').style.left =70+60*Math.sin(2*Math.PI*t[1]/100);
document.getElementById('I1').style.top =70+60*Math.cos(2*Math.PI*t[1]/100);
document.getElementById('I2').style.left =70+60*Math.sin(2*Math.PI*t[2]/100);
document.getElementById('I2').style.top =70+60*Math.cos(2*Math.PI*t[2]/100);
document.getElementById('I3').style.left =70+60*Math.sin(2*Math.PI*t[3]/100);
document.getElementById('I3').style.top =70+60*Math.cos(2*Math.PI*t[3]/100);
}
</script>
</body>
</html>
and it works in IE also





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users