473,474 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

onpageshow and valid xhtml

Just discovered something useful to share.

From Firefox 1.5 in memory caching is used. The onload event only fires when
the page first loads and not when the user navigates away and back to the
page. To ensure code in the onload event fires every time the user moves to
the page you need to use the onpageshow event (which is prioprieyt for
firefox).

At Mozilla Developer Center > Using Firefox 1.5 caching >
http://developer.mozilla.org/en/docs...ox_1.5_caching

The code example fires this event from an XHTML attribute:

<body onpageshow="if (event.persisted) onPageShow();">

The problem: it is not valid XHTML 1.1. To work around this you can just use
the following code in your scripting head (or external file):

window.onpageshow = function (evt) {
if (evt.persisted) window.onload();
}

Of course, you will need to have defined code to run in your onload event.

Tested in Firefox 1.5.0.1 and IE 6.0.


Mar 30 '06 #1
1 9660
Mellow Crow wrote:
From Firefox 1.5 in memory caching is used.
Wrong. Memory caching is used at least since Mozilla/4.x (NN 4.x). And
history caching, which is what you are actually referring to, is used ever
since.
[...]
At Mozilla Developer Center > Using Firefox 1.5 caching >
http://developer.mozilla.org/en/docs...ox_1.5_caching
<rant>
Actually, the bfcache is one reason why Firefox eats as much memory as
it can get, including all available swap space, to date (this reason of
Firefox leaking memory is called a feature by the lead developers as yet).
It is therefore recommended that the bfcache is reduced by changing a
preference.[1] (However, I had to discover recently that only ulimiting
the memory for Firefox really prevents it from locking up this system
through extensive swapping, in the mid-term.)
</rant>
The code example fires this event from an XHTML attribute:

<body onpageshow="if (event.persisted) onPageShow();">

The problem: it is not valid XHTML 1.1. To work around this you can just
use the following code in your scripting head (or external file):

window.onpageshow = function (evt) {
if (evt.persisted) window.onload();
}
This proprietary code is not necessary if XHTML is used, only with HTML.
(See also my sig.) XML applications support the declaration of an internal
subset, that MUST be parsed by an XML processor. So

<!DOCTYPE ...
[
<!ATTLIST body
onpageshow CDATA #IMPLIED ]>

suffices there.
[...]
Tested in Firefox 1.5.0.1 and IE 6.0.


However, IE 6.0 does not support XHTML at all.
PointedEars
___________
[1] <URL:http://weblogs.mozillazine.org/ben/archives/009749.html>
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Mar 30 '06 #2

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

Similar topics

16
by: Justin Koivisto | last post by:
OK, on my quest to get one PHP site that is actually valid XHTML 1.0 (strict)... PHP 4.3.8: session.use_trans_sid=1 What is happening is the validator (that doesn't use cookies) sees things...
5
by: Greg | last post by:
Hi everybody, so, I would like to use XML files for some parts of my website. I would like to respect W3C XHTML 1.1 recommendation. Then, I have these two docs : o My XML file: <?xml...
1
by: Anna | last post by:
Hi all. I have probably a rather stupid question. If there is an HTML document, XML-formed using JTidy, is there any tool to convert it to valid XHTML? I.e. so that all the tags and attribute...
2
by: Michael G | last post by:
Hi, I am really struggling with using form control names such as "gs". This will not valid but is tremendously useful in terms of the way that it is handled by php on the server. Any...
8
by: Anthony Williams | last post by:
Morning all, I'm having a wee problem with a project I'm working on at the moment. I'm leading my company into producing a website, based upon Web Standards, which will be created using XHTML...
9
by: Brian Lowe | last post by:
I'm using Visual Studio to build ASP.Net pages and I'm trying to be standards compliant by using XHTML. In my page I create valid XHTML such as: <ul> <li>first list item</li> <li>second list...
4
by: Lee Chapman | last post by:
Hi, I am having difficulty getting the ASP.NET framework to generate valid XHTML. My immediate problem surrounds user input in, for example, textbox controls. I consider characters such as...
8
by: Alan Silver | last post by:
Hello, I thought that ASP.NET 2.0 was supposed to output valid XHTML 1.0. I've just spent a very frustrating time trying to fix all the validation errors in framework-produced code. I posted...
0
by: Alan Silver | last post by:
Hello, Against my better judgement (due to the pathetic documentation and total lack of support), I'm using FreeTextBox in a project. I have just discovered that it is producing invalid XHTML,...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.