• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Odd jscript problem

xoggoth

More fingers than teeth
Thanks received
1,183
Just found some kid's games I did a few years ago don't work in Chrome or Opera anymore, although still ok in IE and Edge.

Narrowed it down to variables x,y being treated as style properties. This does not work as x, y have no values inside the with:

x = e.pageX - x0; y = e.pageY - y0;
with (imgs[n].style)
{
if (x>=pos(left))
{
blah blah​

Whereas this is ok:

xx = e.pageX - x0; yy = e.pageY - y0;
with (imgs[n].style)
{
if (xx>=pos(left))
{
blah blah​

Can't find anything in CSS style lists to suggest x is a style property. Gotta go through a whole lot of code and change x,y to summit else now. Is it usual for some browsers to invent their own properties and, if so, any lists? Ta.
 
Last edited: 11:07
with statement is deprecated.

but looking at the code, I'm assuming x and y are properties of the argument passed into the with statement "imgs[n].style".
 
Cheers woohoo. Didn't know it was deprecated. Scripts are a few years old.

Doesn't explain why x,y are treated as style properties though, nothing in my jscript or html to account for it.

Fortunately, they all seem to be working again after just changing x,y to xx,yy.
 
Last edited: 18:13
I’m guessing from looking at it that you are passing an image style to the with command.

The with command changes the scope of variables. So it will look at any properties on the passed argument first.

So again guessing here cause I can’t debug, but I imagine theire are properties x and y on the passed argument style.x and style.y.

They may have been introduced on new versions etc.

All just guesses and may be why with is deprecated.
 

Advertisers

Back
Top