Help debug for Explorer

  • Thread starter lindmark.daniel
  • Start date
L

lindmark.daniel

Since I'm a mac-head, I don't have the possibility to make this little
script I wrote work proper on a MSIE browser.
I know there's smarts in here that easily could spot my f**k ups and
tell me what I'm doing wrong.

Code works just fine on Firefox 1.5, Safari 2.0 and Opera (with some
minor buggs)

On explorer, as far as I know, it just produce page errors with cryptic
error messages.

Can anybody help me?

The script

[THE CODE]
function visaLager(id,width,height,speed,opacityTar)
{

// fakey speed convert to ensure int value
var speeda = speed*1

// fetch layer
var el = document.getElementById(id);

// get current size of layer
var h_size1 = el.offsetHeight;
var v_size1 = el.offsetWidth;

// get size of screen
if (self.innerWidth)
{
frameWidth = self.innerWidth;
frameHeight = self.innerHeight;
}
else if (document.documentElement &&
document.documentElement.clientWidth)
{
frameWidth = document.documentElement.clientWidth;
frameHeight = document.documentElement.clientHeight;
}
else if (document.body)
{
frameWidth = document.body.clientWidth;
frameHeight = document.body.clientHeight;
}


var widthStepper = Math.round((width/100) *speeda);
var heightStepper = Math.round((height/100) *speeda);



// the loop the loop
if (h_size1 < width || v_size1 < height)
{
//centers the layer
var topPos = ((frameHeight/2) - (h_size1/2)) + window.pageYOffset;
var leftPos = ((frameWidth/2) - (v_size1/2));

// ensures us that the layer doesnt cover the cats
if(topPos< 200) { topPos = 210; }

// and here we place the layer
el.style.top = topPos + "px";
el.style.left = leftPos + "px";

if(h_size1 < height)
{
// updates the height of the layer
el.style.height = (h_size1 + heightStepper) +"px";
}
if(v_size1 < width)
{
// updates the width of the layer
el.style.width = (v_size1 + widthStepper) +"px";
}


//dont animate opacity in Explorer, just set it
if(!navigator.appName.match("Microsoft"))
{
if(el.style.opacity < (opacityTar/100))
{
var opacity = ((el.style.opacity*10) + 1)/10
el.style.opacity=opacity
}
}else{
el.style.filter="alpha(opacity="+opacityTar+")";
}

// defines a timeout to get that sweet animated effect
r = setTimeout("visaLager('" + id + "','" + width + "','" + height +
"', '" + speed +"','" + opacityTar + "')", 1);

}else{
// clear the timeout when target size is set
clearTimeout(r)
}
}
[/CODE]
 
E

Erwin Moller

Since I'm a mac-head, I don't have the possibility to make this little
script I wrote work proper on a MSIE browser.
I know there's smarts in here that easily could spot my f**k ups and
tell me what I'm doing wrong.

Code works just fine on Firefox 1.5, Safari 2.0 and Opera (with some
minor buggs)

On explorer, as far as I know, it just produce page errors with cryptic
error messages.

Can anybody help me?

Hi Daniel,

Allow me to give you a little unasked advise. ;-)

If you want to publish anything on the web, you have little choice.
You just NEED to get a W$-machine with IE to test your code.

How can you publish your pages without testing it on IE4/5/6 ??

You'll have to test your whole site, not just this piece of JS.
IE, firefox, opera, Safari, etc in all their versions... It is just too much
too 'guess and keep fingers crossed'.

So take your wallet, go buy some W$ OS, and use it as a testmachine.
Or go to somebody in your neighbourhood who has IE running. (In my
neighbourhood more people than I would like are using IE, so I expect it
won't be hard to find one.)

You cannot expect the visitors of this group to do that testing for you. :-/

Futhermore, if you are interested in good books on Javascript or CCS, I
advise:
- Dynamic HTML, the definite Guide (SE) by O'Reilly
- Javascript, the definite Guide (4th edition) also by O'Reilly

Regards,
Erwin Moller

The script

<snipped>
 
L

lindmark.daniel

I rarely code for the web, hence no need to buy a win machine to
betatest, but we got some at the office since I'm the only one on the
mac, but I can't run around on their machines all day, they got to work
to ;)

I would never publish sites for customers without seriously testing
them on every system.
So thanks for the unasked advise, but I'm aware.

I was just hoping that someone could take a quick look and see if they
spotted any easy misstakes, not do my betatesting.
But I will turn elsewhere in the future. : /
 
E

Evertjan.

wrote on 09 mei 2006 in comp.lang.javascript:
I rarely code for the web, hence no need to buy a win machine to
betatest, but we got some at the office since I'm the only one on the
mac, but I can't run around on their machines all day, they got to work
to ;)

I would never publish sites for customers without seriously testing
them on every system.
So thanks for the unasked advise, but I'm aware.

I was just hoping that someone could take a quick look and see if they
spotted any easy misstakes, not do my betatesting.
But I will turn elsewhere in the future. : /

You seem to be touchy about something, but since you are not quoting,
how can we tell about what and whom?

Please always quote on usenet.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at the
top of the article, then click on the "Reply" at the bottom of the
article headers. <URL: http://www.safalra.com/special/googlegroupsreply/
 
E

Erwin Moller

I rarely code for the web, hence no need to buy a win machine to
betatest, but we got some at the office since I'm the only one on the
mac, but I can't run around on their machines all day, they got to work
to ;)


Ok clear.

But still, you want your code to work for IE.
If not, why would you be asking here?
So you do need a M$-machine to test.
As I said in my previous response: There is more to crossbrowserprogramming
than just this piece of JS.
I would never publish sites for customers without seriously testing
them on every system.
So thanks for the unasked advise, but I'm aware.

Good. :)
I was just hoping that someone could take a quick look and see if they
spotted any easy misstakes, not do my betatesting.

If you are lucky, somebody does spot your mistake.

I was not telling you to go away here, that is your oversensitive
interpretation.
I was just trying to warn you about... well you know.
But I will turn elsewhere in the future. : /

Oh, come on. Don't be like that.

Regards,
Erwin Moller
 
L

lindmark.daniel

Oh, come on. Don't be like that. <

Hehe well, I was stressed. And tired of cross-browser issues in js. Why
can't explorer just go away? :D
 
R

Randy Webb

(e-mail address removed) said the following on 5/9/2006 3:59 AM:
Since I'm a mac-head, I don't have the possibility to make this little
script I wrote work proper on a MSIE browser.
I know there's smarts in here that easily could spot my f**k ups and
tell me what I'm doing wrong.

Post a URL to the full page, HTML and all.
Code works just fine on Firefox 1.5, Safari 2.0 and Opera (with some
minor buggs)

On explorer, as far as I know, it just produce page errors with cryptic
error messages.

IE does have some cryptic messages until you get used to them.
Can anybody help me?

The script

[THE CODE]
function visaLager(id,width,height,speed,opacityTar)
{
// fakey speed convert to ensure int value
var speeda = speed*1

var speeda = +speed;

//unary + is faster and simpler than multiply by 1.
//But, that line is unneeded as you multiply with it
//and multiplication does explicit type conversion.
// fetch layer
var el = document.getElementById(id);

if (document.getElementById && document.getElementById(id)){
var el = document.getElementById(id);
}
var topPos = ((frameHeight/2) - (h_size1/2)) + window.pageYOffset;

The above line is your first error. IE doesn't support pageYOffset, it
uses scrollTop and it gets even stranger as it depends on the doctype in
use how you go about getting it.

<snip>

I didn't hunt more errors after that one.
 
L

lindmark.daniel

thanks Randy, I will look deeper into those lines.
On a sidenote, does anyone know if there's a debugger extension of some
sort to MSIE? For looking at DOM Trees and such.
Firefox has some useful extensions and Safari has a what they call
"Debug menu".
 
E

Erwin Moller

Hehe well, I was stressed. And tired of cross-browser issues in js. Why
can't explorer just go away? :D

Hi,

Crossbrowser issues are really annoying.
Everybody thinks the same.

The two books I recommended to you in my other posting are a GREAT help
coding things the right from the start.

They are both aimed to be comprehensive and the authors really did a great
job to present all cross-browser-issues in way everybody can easily
understand.
Both books also try to find the common ground for all browsers.
Once you master that part, crossbrowser scripting becomes a lot easier.

I always start looking for solutions that are presented in the chapters of
the books that descripe the 'common api'.

If you have time, read them.

I know, when you have presure to finish some project, you don't have time to
study a book, but in the end they pay back the time manyfold you invest in
them. :)

/me loves O'Reilly series.

Good luck.

Regards,
Erwin Moller
 
L

lindmark.daniel

Yeah I should get some books, then again, the net have so much already,
to bad you have to go looking for it :p
when all the information I need comes to me without me needing to do
anything I will declare the web "2.0", until thenI say it's still just
1 (ok 1.5 then).

This is actually the first time I try to write something a little more
complex (than form and window flirks) from scratch out of what I picked
up from around. My only real experience from js otherwise is singel
plattform development for our intranet and the AS approach to it in
flash.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated
Tue, 9 May 2006 07:20:55 remote, seen in
Randy Webb said:
var speeda = +speed;

//unary + is faster and simpler than multiply by 1.
//But, that line is unneeded as you multiply with it
//and multiplication does explicit type conversion.

Since speeda is used repeatedly (ISTM) after that, it may be better to
do a single explicit conversion there rather than repeated ones later
on; but it will not make much difference.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top