By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,434 Members | 2,884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,434 IT Pros & Developers. It's quick & easy.

calling link in other frame

P: n/a
Hi,

I would like to call a link in a frame every second but with a different GET
parameter to recognize the time, how long a user has been on the page, i
did this with following script:

<html><head>
<script language="JavaScript" type="text/JavaScript">
var start = new Date();
function time()
{
var now = new Date();
seconds=parseInt((now.getTime() - start.getTime()) / 1000);
parent.nullframe.location = "nullframe.php?email=<?php echo
$_SESSION['email'] ?>&duration=" + seconds + "";
setTimeout("zeit()", 1000);
}
</script>
</head>
<body onLoad="time();">
</form></body></html>

The error console gives no errors, so it seems to be good but somehow it
loads the page once only and the setTimeout("zeit()", 1000); call doesn't
seem to call
Dec 18 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ron Eggler said the following on 12/17/2007 7:47 PM:
Hi,

I would like to call a link in a frame every second but with a different GET
parameter to recognize the time, how long a user has been on the page, i
did this with following script:
No DOCTYPE.
<html><head>
<script language="JavaScript" type="text/JavaScript">
Drop the deprecated language attribute and keep the comical type
attribute. Validating would have let you know that.
var start = new Date();
function time()
{
var now = new Date();
seconds=parseInt((now.getTime() - start.getTime()) / 1000);
parent.nullframe.location = "nullframe.php?email=<?php echo
$_SESSION['email'] ?>&duration=" + seconds + "";
Don't post PHP code. Post the HTML the browser gets.
setTimeout("zeit()", 1000);
Where is the function zeit() defined?
}
</script>
</head>
<body onLoad="time();">
</form></body></html>

The error console gives no errors, so it seems to be good but somehow it
loads the page once only and the setTimeout("zeit()", 1000); call doesn't
seem to call
Probably because it isn't defined in the code you posted.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 18 '07 #2

P: n/a
In comp.lang.javascript message <MME9j.131$pY1.33@pd7urf2no>, Tue, 18
Dec 2007 00:47:40, Ron Eggler <NO*****@example.composted:
>seconds=parseInt((now.getTime() - start.getTime()) / 1000);
You should use Math.floor, not parseInt, there. Or you could use |0.
The two .getTime() are OK but superfluous.

It's a good idea to read the newsgroup c.l.j and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
news:comp.lang.javascript FAQ <URL:http://www.jibbering.com/faq/index.html>.
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Dec 19 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.