小编And*_*rew的帖子

Firefox contentEditable div焦点问题

contentEditable在我的网站上使用div标签,我注意到使用Firefox时有一个奇怪的问题.

这是示例源代码:

<html>
  <head>
  </head>
  <body>
    <div contentEditable="true" style="margin-left:auto; 
         margin-right:auto; height:200px; width:200px; border-style:solid; 
         border-color:black; border-width:1px;"></div>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

以下是重现的步骤.

  1. contentEditable 有焦点,光标在div内闪烁,但div中没有​​文字
  2. 用户点击contentEditable div
  3. div仍显示焦点,但现在没有闪烁的光标,用户无法输入div

我在Ubuntu上用Firefox 3.6.3和Windows XP上的Firefox 3.5重现了这个错误.Chrome不会发生这种情况.

关于为什么会发生这种情况以及如何解决这个问题的想法?

编辑:一种可能的解决方法可能是手动设置光标所在的位置.有谁知道如何做到这一点?我一直在网上搜索,但看起来没有W3支持.

谢谢!

html css firefox focus contenteditable

6
推荐指数
1
解决办法
5688
查看次数

在ruby中按value属性选择哈希值

在Ruby中,我有一个对象哈希.每个对象都有一个类型和一个值.我试图设计一个有效的函数,可以获得散列中特定类型的所有对象的平均值.

以下是当前如何实现此示例的示例:

#the hash is composed of a number of objects of class Robot (example name)
class Robot
  attr_accessor :type, :value

  def initialize(type, value)
    @type = type
    @value = value
  end

end


#this is the hash that inclues the Robot objects
hsh = { 56 => Robot.new(:x, 5), 21 => Robot.new(:x, 25), 45 => Robot.new(:x, 35), 31 => Robot.new(:y, 15), 0 => Robot.new(:y, 5) }


#this is the part where I find the average
total = 0
count = 0 …
Run Code Online (Sandbox Code Playgroud)

ruby arrays algorithm hash performance

1
推荐指数
1
解决办法
4988
查看次数

标签 统计

algorithm ×1

arrays ×1

contenteditable ×1

css ×1

firefox ×1

focus ×1

hash ×1

html ×1

performance ×1

ruby ×1