473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

When was the page loaded?

Is there a way for a bookmarklet to know, when exactly the page was loaded
or refreshed? If yes, how? :)
Aug 4 '08 #1
10 1548
optimistx wrote:
Is there a way for a bookmarklet to know, when exactly the page was loaded
or refreshed?
Unlikely.
PoinetdEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Aug 4 '08 #2
optimistx wrote:
Is there a way for a bookmarklet to know, when exactly the page was loaded
or refreshed? If yes, how?
It should be no problem to show when the page was first loaded. Just
store a cookie at the first visit of the user with the date in it, and
then read it out at every next visit. The problem here is the refresh.
Perhaps better is a server-side solution (eg. PHP), let it generate
the date, put it in a js variable, and show that variable in the
bookmarklet. This way the refresh should also be included.

Hope this helps,

--
Bart
Aug 4 '08 #3
On Aug 4, 10:42*am, Bart Van der Donck <b...@nijlen.comwrote:
optimistx wrote:
Is there a way for a bookmarklet to know, when exactly the page was loaded
or refreshed? If yes, how?

It should be no problem to show when the page was first loaded. Just
store a cookie at the first visit of the user with the date in it, and
then read it out at every next visit. The problem here is the refresh.
Perhaps better is a server-side solution (eg. PHP), let it generate
the date, put it in a js variable, and show that variable in the
bookmarklet. This way the refresh should also be included.

Hope this helps,

--
*Bart
Or keep two cookies. The first (first loaded) only gets updated if it
doesn't exist...the second (last refresh) gets updated on each load
whether it exists or not.
Aug 4 '08 #4
On Aug 4, 5:10 pm, Tom Cole wrote:
On Aug 4, 10:42 am, Bart Van der Donck wrote:
>optimistx wrote:
>>Is there a way for a bookmarklet to know, when exactly the page
^^^^^^^^^^^^^
>>was loaded or refreshed? If yes, how?
>It should be no problem to show when the page was first loaded.
Just store a cookie at the first visit of the user with the
date in it, ...
<snip>
Or keep two cookies. The first (first loaded) only gets
updated if it doesn't exist...the second (last refresh) gets
updated on each load whether it exists or not.
It would be unusual for a script triggered with a bookmarklet to have
the opportunity to influence the load events of the pages upon which
it operated, and no chance of employing server-side technology.
Aug 4 '08 #5
Henry wrote:
On Aug 4, 5:10 pm, Tom Cole wrote:
>On Aug 4, 10:42 am, Bart Van der Donck wrote:
>>optimistx wrote:
Is there a way for a bookmarklet to know, when exactly the page
^^^^^^^^^^^^^
>>>was loaded or refreshed? If yes, how?
>>It should be no problem to show when the page was first loaded.
Just store a cookie at the first visit of the user with the
date in it, ...
<snip>
>Or keep two cookies. The first (first loaded) only gets
updated if it doesn't exist...the second (last refresh) gets
updated on each load whether it exists or not.

It would be unusual for a script triggered with a bookmarklet to have
the opportunity to influence the load events of the pages upon which
it operated, and no chance of employing server-side technology.
Thanks for the ideas.
If the bookmarklet creates cookies in the client machine, and reads them
next
time the page is loaded from the server , the bookmarklet gets the cookies
at least several seconds after the the page has been loaded (after the
person has hit the bookmarklet button or menu). The bookmarklet has no
control of the server side (in this case). The cookie created by the
bookmarklet cannot contain the time when the server has sent it or the
client received (?).
Http-response headers might have the page creation time, but can the
bookmarklet read them?
I do not expect the bookmarklet to 'influence' the loading , but it would be
nice to know how much time the client has been studying the page before
activating the bookmarklet. This is not a very important question, but 'nice
to know' - type of thing.
Aug 4 '08 #6
Tom Cole wrote:
On Aug 4, 10:42*am, Bart Van der Donck <b...@nijlen.comwrote:
>optimistx wrote:
>>Is there a way for a bookmarklet to know, when exactly the page was
loaded or refreshed? If yes, how?
>It should be no problem to show when the page was first loaded. Just
store a cookie at the first visit of the user with the date in it, and
then read it out at every next visit. The problem here is the refresh.
[...]

Or keep two cookies. The first (first loaded) only gets updated if it
doesn't exist...the second (last refresh) gets updated on each load
whether it exists or not.
The second cookie would indeed indicate the last page view ("load"),
but that is not necessarily a refresh.

--
Bart
Aug 5 '08 #7
Bart Van der Donck wrote:
....
The second cookie would indeed indicate the last page view ("load"),
but that is not necessarily a refresh.
I do not understand this yet. My problem is, whether the client has been
looking at the page some seconds or some minutes before hitting the
bookmarklet.
How would the 2-cookie idea solve this exactly?
Aug 6 '08 #8
optimistx wrote:
[...]
I do not understand this yet. My problem is, whether the client has been
looking at the page some seconds or some minutes before hitting the
bookmarklet.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<title>Bookmarklet</title>
<script type="text/javascript">
var s = 0;
function addsec() {
++s;
setTimeout('addsec()', 1000);
}
</script>
</head>
<body onLoad="addsec();">
<p><a href="javascript:alert(s + ' seconds')">Bookmarklet</a></p>
</body>
</html>

--
Bart
Aug 7 '08 #9
Bart Van der Donck wrote:
optimistx wrote:
>[...]
I do not understand this yet. My problem is, whether the client has
been looking at the page some seconds or some minutes before hitting
the bookmarklet.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
<title>Bookmarklet</title>
<script type="text/javascript">
var s = 0;
function addsec() {
++s;
setTimeout('addsec()', 1000);
}
</script>
</head>
<body onLoad="addsec();">
<p><a href="javascript:alert(s + ' seconds')">Bookmarklet</a></p>
</body>
</html>
Thanks for the example. However, the bookmarklet code is inserted to a page,
which can have come from any domain, and thus the onLoad event is not useful
for the bookmarklet ( the event might have happened minutes earlier).
Aug 8 '08 #10
optimistx wrote:
Bart Van der Donck wrote:
>*<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
* "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
*<html>
*<head>
*<title>Bookmarklet</title>
* <script type="text/javascript">
* * *var s = 0;
* * *function addsec() *{
* * * *++s;
* * * *setTimeout('addsec()', 1000);
* * *}
* </script>
*</head>
*<body onLoad="addsec();">
* <p><a href="javascript:alert(s + ' seconds')">Bookmarklet</a></p>
*</body>
*</html>

Thanks for the example. However, the bookmarklet code is inserted to a page,
which can have come from any domain, and thus the onLoad event is not useful
for the bookmarklet (the event might have happened minutes earlier).
If you want a sheer javascript solution, I think you need javascript
code outside of the bookmarklet anyhow, because one way or another,
the start time must be initialized. And that is something a
bookmarklet can't do. That start time doesn't need to be in an onLoad-
event Per Se, although that would be the recommended way.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Bookmarklet</title>
<script type="text/javascript">
var e = (new Date()).getTime();
</script>
</head>
<body>
<a href="javascript:alert(((new Date()).getTime()-e)/1000+' sec')">
Bookmarklet
</a>
</body>
</html>

The start time could also be initialized by server (php, asp, perl,
ssi, ...). In that case, no javascript code outside the bookmarklet is
needed.

--
Bart
Aug 8 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Richard Bell | last post by:
Newbie question ... please respond to group I'm trying to open/navigate to a url. How can I tell when the page is fully loaded? Testing suggest that window.open returns before the page is...
3
by: foldface | last post by:
Hi Given a web page using frames, is there anyway the left frame can request a page in the right frame and, most importantly, detect when it has fully loaded? Ideally this requires no changes to...
9
by: Ian Richardson | last post by:
If I follow the steps on http://www.dhtmlcentral.com/tutorials/tutorials.asp?id=11 to add .js files to a document on demand, let's say by <body onload="blah();">, how can I reliably tell that it...
5
by: aladdinm1 | last post by:
Hi All, I have an annoying trouble with binary serialization. I have a windows forms application which works like a server and keeps sending data to its clients. The data is serialized before...
0
by: Chee | last post by:
Hi all Please forgive me if this has been asked before. I am getting a ThreadAbortException in "Unknown Module" when i try to load a page from VS.NET. One problem is it does not happen all the...
2
by: Alan Silver | last post by:
Hello, I'm having rather a problem with user control. It is a fairly simple affair (see my other threads for more details) that shows a date and time in five drop down controls. I had private...
6
by: sylcheung | last post by:
Hi, How can I be notified when the document load is complet in JavaScript? I am referring to the whold document load is complete, mean all images/external files/frame/iframes have been loaded. ...
2
by: Smithers | last post by:
My ASP.NET Web app uses a few 3rd party assemblies. Just wondering when those are loaded into the Web app's AppDomain - and for how long do they stay loaded. Is an assembly loaded the first time...
4
by: Nicolas R | last post by:
Hi all, Im trying to figure out how to display a 'loading' message when scripts are being executed, ie when the page is still not ready for interaction. This is for a web app which relies on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.