[whatwg] Save a web page
Lachlan Hunt
lachlan.hunt at iinet.net.au
Fri Jul 2 01:00:06 PDT 2004
Edmund Lai wrote:
> All I am asking is that if the browser saves the page, fire a onSave
> event first.
As a user, I would not want any such feature. When I save a page, I
expect it to be saved unaltered, except maybe image, script and css
paths, if they're saved as well. Unfortunately, current browsers break
this rule [1].
An onSave event would allow the author control over something that
only the user and the user agent should be able to control. With an
onSave event, an author could, for example, set off a function that will
remove all content from the page, in a febal attempt to protect their
copyright from the average user. eg.
function onSaveEventHandler() {
var body = document.getElementsByTagName("body");
// Remove all child nodes of <body>
while (body[0].hasChildNodes) {
body[0].removeChild(body[0].childNodes[0]);
}
// Create warning message
var text = document.createTextNode("Sorry, you cannot save this
document");
var p = document.createElement("p");
p.appendChild(text);
// Add warning message to body
body[0].appendChild(p);
}
Despite the fact that computer literate people like us can usually
get around evil scripts like that, the majority of user's won't know
how, and will just get frustrated.
It is the user agent's job to save the document, not the authors,
thus the user agent, with the user's permission, should have control. I
would support user agents providing an *option* to save the current form
field values, but that *must* be the choice of the user to do so, not
the author or user agent. So, it is definately out of the scope of WF2
[1] Note: Mozilla and IE (I think), when saving as a complete web page
(including images, script, css, etc.), attempt to convert XHTML to HTML
when it's been served as text/html, without changing the DOCTYPE, so any
XHTML document saved becomed invalid, because all the closing / are
removed from empty elements. I get around this with Mozilla by using
HTML only option.
--
Lachlan Hunt
http://www.lachy.id.au/
lachlan.hunt at lachy.id.au
More information about the whatwg
mailing list