Search code examples
javascriptinternet-explorer-6scripting

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


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>?


Solution

  • 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