homepage Welcome to WebmasterWorld Guest from 54.204.231.253
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
JS ERROR with Windows 7 - 64bits
The code is fine but doesn't work with Win7 - 64bits.
explorador




msg:4373394
 9:07 pm on Oct 11, 2011 (gmt 0)

Hi, suddenly one of my scripts began trowing errors but the code is fine. I checked and somehow getting the date object and data doesn't work with ANY of my browser under WIN7 64. Opera, IE, FF, Safari... none.

I checked the w3schools example and the one with milliseconds gets 0 as a result. Any ideas on how to get around this?

[w3schools.com...]


I tested my app under every browser on Windows and several browsers under Ubuntu Linux, no problem, only with Windows7 64 bits.... weird...

 

explorador




msg:4373397
 9:11 pm on Oct 11, 2011 (gmt 0)

Forgot to add: I searched the web but I don't seem to find others with the problem. Could it be anything else that only applies to me in this case? double checked, no idea.

explorador




msg:4373421
 10:23 pm on Oct 11, 2011 (gmt 0)

For get what I wrote, the code is fine, but the short way is not working, the long way it is (win7 x64), on the rest of systems doesn't need modifications. Not solved but... solved!

penders




msg:4373431
 10:50 pm on Oct 11, 2011 (gmt 0)

Just to clarify, are using saying the following returns 0 under Win7 64bit?

var d = new Date(); 
document.writeln(d.getMilliseconds());


...and the long way uses getTime()?

explorador




msg:4373440
 11:21 pm on Oct 11, 2011 (gmt 0)

Just to clarify, are using saying the following returns 0 under Win7 64bit?


The following page "try it" gives me 0 every time, unless that's what is supposed to result... </clueless>

[w3schools.com...]


The code has been working fine with every browser, but now at work have a new machine with Win7 x64, and this is the first time I'm getting this error.

In the function I was generating a 13 digit number using the hour, minutes, seconds, etc using one line ++++, now I used one var for each part of the long digit and then joined them, now it works. Very strange. Sorry for the confusion.

penders




msg:4373465
 12:58 am on Oct 12, 2011 (gmt 0)

The following page "try it" gives me 0 every time, unless that's what is supposed to result...


Yes, that is the expected result in that particular example since the time portion of the string does not specify the number of milliseconds. It returns 0 in the same way that getSeconds() also returns 0.

However, my code example above (which is actually Example#1 from the w3schools page you link to) should give a result in the range 0-999. The w3schools example on that page is a live example, so refreshing the page a few times should give different results.

I don't have access to Win7 64bit, but I would guess it was something else that is breaking!? :) With a 64bit OS it is quite possible you could get different results from floating-point arithmetic expressions due to the increased precision - although I'm not sure how that would come into play here.

I would be interested to see the code which you say isn't working.

Btw, getTime() returns the internal representation of the Date object in milliseconds, which is currently a 13 digit number.

explorador




msg:4373636
 2:14 pm on Oct 12, 2011 (gmt 0)

Thanks penders for the correction.
I would be interested to see the code which you say isn't working.

I was getting the numbers and adding them one to another in one line, it was working, but suddenly instead of forming a long string they began to sum into one number (as numbers not as strings). I thought about the milliseconds becase when I started removing parts of the line, removing that one seemed to work. The code was fixed, since I removed that part in the first place I'm not sure anymore, perhaps it was something that was modified along the way on my multireplacements (working with several scripts at once on my editor).

Thanks, I was worried about it.

penders




msg:4373768
 7:08 pm on Oct 12, 2011 (gmt 0)

I was getting the numbers and adding them one to another in one line, it was working, but suddenly instead of forming a long string they began to sum into one number (as numbers not as strings).


I was wondering if this might have been happening - it can be the cause of many a problem. If all parts of the expression are numbers then '+' should numerically add them all together. However, since '+' is also the string concatenation operator, then JavaScript determines at runtime, depending on the data types of the operands exactly what to do. And this can sometimes give unexpected results.

However, why this should behave differently on Win7 64bit is still a bit of a mystery, other than the fact that a 64bit OS will have a far greater numeric range before the numbers overflow. On a 32bit OS the numbers might result in overflow and so JS resorts to string concatenation - but that is a wild guess!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved