Forum Moderators: open

Message Too Old, No Replies

Javasript Error on Safari

Implemented a page refresh script that works fine on FireFox & IE

         

aramanujan

5:24 pm on Sep 28, 2005 (gmt 0)

10+ Year Member



Hi,

I implemened a javascript on a news wesbite, so the page refreshes each time someone visits the site instead of serving up from their cache.

But this seems to have made the page unusable on safari.

Any Ideas?

Here's the code:
<SCRIPT LANGUAGE="JavaScript"><!--
function y2k(number) { return (number < 1000)? number + 1900 : number; }

var now = new Date();
var nowsecs = Date.UTC(y2k(now.getYear()),now.getMonth(),now.getDate(),now.getHours(),now.getMinutes(),now.getSeconds());

if (location.search) {
var thensecs = location.search.substring(1);
var difference = nowsecs - thensecs;
if ((nowsecs - thensecs) > 10000) {
location.replace(location.href.substring(0,location.href.length - location.search.length) + '?' + nowsecs)
}
}
else {
location.replace(location.href + '?' + nowsecs);
}
//--></SCRIPT>

Here are some user complains:

Safari Omniweb 4.4: Continous restarts, 3-4 after every article
Safari 2.0.1 Mac OSX : Browser will not load home page
Safari 1.2.3 Mac Panther 10.3:Page keeps Re-loading over and over.

aramanujan

8:45 pm on Sep 28, 2005 (gmt 0)

10+ Year Member



Anyone having problems with safari and javascript in general?

Rambo Tribble

3:01 am on Sep 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let me suggest, since the UTC method of the Date object requires its inputs in UTC format:

Date.UTC(now.getUTCFullYear(),now.getUTCMonth(),now.getUTCDate(),now.getUTCHours(),now.getUTCMinutes(),now.getUTCSeconds())

Additionally, you may wish to consider running Linux, as that way you can test on Konqueror, Safari's less sinister twin. I would recommend a Debian-based distro, such as Xandros or Ubuntu. Xandros will painlessly install beside Windows and allow you a quality operating system experience. Quanta Plus is an excellent web editor, working well with (X)HTML, JavaScript, and PHP.

aramanujan

3:46 am on Sep 29, 2005 (gmt 0)

10+ Year Member



Thanks RT - I will see if this works.