开发者

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


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


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 something like this :

  1. Input will have value "password" at the beginning
  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 please.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜