简体   繁体   English

鬼文字在ie9中不起作用

[英]ghost text is not working in ie9

I am using ghost text in all the browser it is working fine but in ie9 or ie8 not. 我在所有浏览器中都使用了幽灵文本,但是在ie9或ie8中却无法正常工作。 step-1 load the page step-2 enter submit validation message came step3-place the cursor on particular field ghost text is not removing.(w/o enter submit button cursor placed on particular field ghost text is gone off). 步骤1加载页面步骤2输入提交验证消息来到步骤3将光标移到特定字段幻影文本上没有删除(不输入放置在特定字段幻影文本上的提交按钮光标消失了)。

My code as below. 我的代码如下。

<?php
echo $this->Form->input('service_address1', array(
    'id'        => 'address1',
    'div'       => false,
    'label'     => false, 
    'tabindex'  => '0',
    'class'     => 'form-bg',
    'maxlength' => 250,
    'value'     => 'Address',
    'onblur'    => "if(this.value=='') { this.value='Address'; }",
    "onfocus"   => "if(this.value == 'Address') { this.value = ''; }"
));
?>    

Your code is fine. 您的代码很好。 Please check any issue in your other codes in the same page. 请在同一页面中检查其他代码中的任何问题。 May be the issue is coming from your script code if you are using any script functions. 如果您使用任何脚本功能,则可能是脚本代码引起的问题。

  1. In IE8 and IE9 Press F12 , it will show the console option 在IE8和IE9中,按F12键 ,将显示控制台选项
  2. Refresh your page and check if any issue showing on the page 刷新页面并检查页面上是否显示任何问题
  3. Proceed with Submit 继续提交

If have any bugs or error in script it will showing on the console. 如果脚本中有任何错误或错误,它将显示在控制台上。

This is a bug in IE9 and reported at many places as well. 这是IE9中的错误,很多地方也有报道。 Whenever a table renders multiple rows dynamically. 每当表动态呈现多行时。 IE 9 creates some ghost cells which are unwanted and disturbs the alignment of the UI. IE 9创建了一些不需要的幻像单元 ,并干扰了UI的对齐。

So to prevent the unwanted ghost cells in your html table while rendering, just use this useful script 因此,为防止在渲染时html表中不必要的鬼单元格,只需使用此有用的脚本

function removeWhiteSpaces()
{
   $('#myTable').html(function(i, el) {
      return el.replace(/>\s*</g, '><');
   });
}

This javascript function you should call when the page loads (ie onload event ) 页面加载时应调用此javascript函数(即onload事件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM