You are here: Re: Stopping browser prompts in forms « HTML « IT news, forums, messages
Re: Stopping browser prompts in forms

Posted by Thomas 'PointedEars' Lahn on 08/10/07 19:24

Gregor Kofler wrote:
> Thomas 'PointedEars' Lahn meinte:
>> Gregor Kofler wrote:
>>> Thomas 'PointedEars' Lahn meinte:
>>>> Gregor Kofler wrote:
>>>>> Some browser know a "autocomplete"-attribute for input fields.
>>>>> autocomplete="off" might help.
>>>> If that was the case (I have not tested it), the attribute should be either
>>>> be declared (which however fails when parsed as tagsoup-HTML) or its value
>>>> set through a properly feature-tested DOM element property, because using it
>>>> as above would create invalid markup.
>>> Well, I never stated that it is valid.
>> And you have not stated that it is not Valid, hence my remark.

In fact, "not Valid" is a bit exaggerated. It is not (and AIUI cannot be
made) Valid HTML. It can be made Valid XHTML by declaring the attribute, as
mentioned above:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/dtd/xhtml1-strict.dtd"
[
<!ATTLIST input
autocomplete (off|on) "on"
>
]>

But the problem is that XHTML itself is not interoperable yet, and when
parsed by a tagsoup parser (which is highly likely if served as
IE-compatible text/html), part of the declaration is displayed (even with
Geckos, which is most unfortunate as they do have an XML parser.)

Therefore, trying to address this proprietary feature with an equally
proprietary property of the corresponding DOM element object appears to be
one of the better solutions. Especially since client-side scripting is
involved here anyway. For example:

....
<head>
...
<meta http-equiv="Content-Script-Type" content="text/javascript"></meta>
<script type="text/javascript">
// <![CDATA[
/**
* @depends http://pointedears.de/scripts/types.js
*/
function disableAutoComplete(f)
{
if (f)
{
for (var es = f.elements, i = es && es.length; i--;)
{
var e = es[i];
if (e.tagName.toLowerCase() == "input"
&& e.type.toLowerCase() == "text")
{
if (typeof e.autoComplete == "string")
{
e.autoComplete = "off";
}
else if (isMethodType(typeof e.setAttribute)
&& e.setAttribute)
{
e.setAttribute("autocomplete", "off");
}
}
}
}
}
// ]]>
</script>
</head>

<body onload="disableAutoComplete(document.forms[0])">
<form ...>
...
</form>
...
</body>


F'up2 cljs

PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация