views:

303

answers:

2

In this blog, http://www.bswebdev.com/2008/12/javascript-change-input-box-type-to-password/ I have found the following snippets for fixing change input type through javascript in IE6.

 <script type="text/javascript"><!--mce:0--></script>
 # put the script in the head of your html
 <input id="pw" name="password" type="text" value="Password" />

What is <script type="text/javascript"><!--mce:0--></script>?

+2  A: 

Short answer: Junk

Longer answer:

In XHTML: It is an empty script element.

In HTML: It is a 0 evaluated in null context (so it is discarded without doing anything) and with a label (with no block!) 'mce'. This is combined with a broken (because it is all on one line) "hide from Netscape 2 comment".

I suspect the author made a few mistakes when trying to write up their idea using their blog software.


The whole thing it is trying to achieve is a dirty hack anyway. It is trying to work around a side effect of abusing the value attribute as a label. If you really want to have your labels vanish when you enter text into the fields, then use real <label> elements and hide them. e.g. http://dorward.me.uk/tmp/label-work/example.html

David Dorward
@David Dorward or he could set input background image as "Password", and field type is always password, so when he focuses the background is transparent, when he blurs out if the input is still empty switch "Password" image back.
c0mrade
`mce:` doesn't have to be a "loop label" -- it's simply a "label" ... Which constructs a `LabelledStatement` - http://bclary.com/2004/11/07/#a-12.12
J-P
@c0mrade — that suffers from the usual issues that pictures of text have. A `<label>` is available to everybody.
David Dorward
c0mrade
A: 

I had a similar problem before, there is another way of looking at this problem, what exactly are you trying to accomplish, are you trying somethink like this :

  1. Input will have value "password" at the begining
  2. When you focus and start typing it should mask the characters
  3. When you focus out the "password" value will return

Is this what you seek, or? be more specific pls

c0mrade