浏览器问题将元素类型切换为textarea并设置焦点 [英] Browser problems switching element type to textarea and setting focus

查看:53
本文介绍了浏览器问题将元素类型切换为textarea并设置焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在flickr照片标题庄园中找到用于编辑文本的跨浏览器解决方案,其中文本显示在< div>中。或者< a>标记,但更改为< textarea>单击时通过JS。


有两个问题。

1.将焦点设置在新textarea上

2.在切换回普通文本时保留新文本值。

Firefox:聚焦很好但没有保留新的文本值
Safari:聚焦然后立即失去焦点,并且可能无法保留新文本。
EI:没有设置焦点,但保留了新的文本值。


这里可以看到包含js的示例页面:
http://macrophotography.com/test.html


任意建议或帮助弄清楚发生了什么将非常感激。我是JS的初学者。


谢谢!

Bugboy

I''m trying to find a cross browser solution for editing text in a flickr photo caption manor where the text is displayed in a <div> or <a> tag but changes to a <textarea> via JS when clicked.

There are two problems.
1. setting the focus on the new textarea
2. keeping the new text value when switching back to normal text.

Firefox: focuses fine but does not keep the new text value
Safari: focuses then instantly looses focus again, and may not keep new text.
EI: does not set focus but does keep the new text value.

An example page including js can be seen here:
http://macrophotography.com/test.html

Any suggestion or help in figuring out what is happening would be greatly appreciated. I''m a beginner at JS.

Thanks!
Bugboy

推荐答案

问题使用firefox在你的函数a_state中,你正在使用:

The problem with firefox is in your function a_state, you are using:

展开 | 选择 | Wrap | 行号


我需要将焦点设置为一个动态添加的textarea。我正在使用:
I need to set the focus to a dynamically added textarea. I''m currently using:
展开 | 选择 | Wrap | 行号


可以发布您尝试的代码...



问候

Ramanan Kalirajan
Can u pls post the code what u have tried...


Regards
Ramanan Kalirajan


这篇关于浏览器问题将元素类型切换为textarea并设置焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆