问个关于剪贴板的问题。clipboardData.setData("HTML",)到底怎么用?

huolx 2002-05-30 07:59:34
将文本数据复制到剪贴板我会用,
clipboardData.setData("Text","test");
HTML的数据我怎么试也不行
clipboardData.setData("HTML",到底怎么用?)
...全文
1155 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
huolx 2002-06-01
  • 打赏
  • 举报
回复
可是我要把它加到当前光标所在处呀,这样做不是加到最后了?所以我才要用剪贴板~~
麻烦秋水同志再想想~~
谢谢。
qiushuiwuhen 2002-06-01
  • 打赏
  • 举报
回复
<iframe id=demo src="about:<body>hi,test"></iframe>
<input type=button onclick=addImage() value=addImage>
<script>
function addImage(){
demo.document.body.innerHTML+='<img src="aaa.jpg" alt="gggg" align="left">'
}
demo.document.designMode="on"
</script>
huolx 2002-06-01
  • 打赏
  • 举报
回复
up
huolx 2002-06-01
  • 打赏
  • 举报
回复
高!
demo.focus();
就是没想出用这个来~~~~~~~~
qiushuiwuhen 2002-06-01
  • 打赏
  • 举报
回复
别up了,呵呵,看看
http://www.blueidea.com/bbs/newsdetail.asp?id=461596
就会明白的


<iframe id=demo src="about:<body>hi,test"></iframe>
<input type=button onclick=addImage() value=addImage>
<script>
function addImage(){
var html='<img src="aaa.jpg" alt="gggg" align="left">'
demo.focus();
demo.document.selection.createRange().pasteHTML(html)
}
demo.document.designMode="on"
</script>

huolx 2002-06-01
  • 打赏
  • 举报
回复
Up
huolx 2002-05-31
  • 打赏
  • 举报
回复
up
孟子E章 2002-05-31
  • 打赏
  • 举报
回复
你说的那些参数是别的应用程序支持的,比如/:interdav,dreamweaver等
huolx 2002-05-31
  • 打赏
  • 举报
回复
<br>可以用\n
可我只是举个例子,我实际想插入的是
<img src="aaa.jpg" alt="gggg" align="left">
这怎么办?
qiushuiwuhen 2002-05-31
  • 打赏
  • 举报
回复
<br>
=>
\n
linhaibo 2002-05-31
  • 打赏
  • 举报
回复
Text,URL,File,HTML,Image

好东西,不过对于IE来说,只支持 Text,URL

如果来自外部程序的,可以直接使用 paste 方法,对 Image ,HTML 有效
huolx 2002-05-31
  • 打赏
  • 举报
回复
to:linhaibo(美洲豹): paste 方法?他是哪个对象的方法?能举个例子吗?

to all:我现在是想向一个在线编辑器(用iframe做的那种)中插入一段html代码,举个例子:如果直接用
clipboardData.setData("Text","test<br>test");将数据复制到剪贴板
用clipboardData.getData("text"),贴上去后是直接将html标记也显示出来了
成了这样
test<br>test
而不是我想要的
test
test

该怎么办?
saucer 2002-05-30
  • 打赏
  • 举报
回复
from MSDN (http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/setdata.asp?frame=true)

setData Method

Assigns data in a specified format to the dataTransfer or clipboardData object.

Syntax

bSuccess = object.setData(sDataFormat, sData)

Parameters

sDataFormat
Required. String that specifies the format of the data to be transferred, using one of the following values:
Text Transfers data formatted as text.
URL Transfers data formatted as a URL.

sData
Required. String that specifies the data supplied by the source object. This information can be descriptive text, a source path to an image, or a URL for an anchor. When you pass "URL" as the sDataFormat parameter, you must use the sData parameter to provide the location of the object being transferred.
huolx 2002-05-30
  • 打赏
  • 举报
回复
可我看的那本《javascript宝典》(电子工业出版社译,99元)
上面说:
setData(format,data)
返回值Boolean
存储字符串数据格式是以下之一:Text,URL,File,HTML,Image。对非文本数据格式,数据必须是字符串,它必须指定到当前内容的路径或者URL。
原来感觉这本书还不错,怎么犯这种错误?要不就是我理解错了,到底怎么回事?

qiushuiwuhen 2002-05-30
  • 打赏
  • 举报
回复
HTML不也是文本(Text)数据么?
qiushuiwuhen 2002-05-30
  • 打赏
  • 举报
回复
HTML不也是文本(Text)数据么?
qiushuiwuhen 2002-05-30
  • 打赏
  • 举报
回复
HTML不也是文本(Text)数据么?
孟子E章 2002-05-30
  • 打赏
  • 举报
回复
Syntax

bSuccess = object.setData(sDataFormat, sData)

Parameters

sDataFormat Required.
String that specifies the format of the data to be transferred, using one of the following values:

Text Transfers data formatted as text.
URL Transfers data formatted as a URL.

sData Required.
String that specifies the data supplied by the source object. This information can be descriptive text, a source path to an image, or a URL for an anchor. When you pass "URL" as the sDataFormat parameter, you must use the sData parameter to provide the location of the object being transferred.

Return Value

Boolean. Returns one of the following possible values:

true The data was successfully added.
false The data was not added.
孟子E章 2002-05-30
  • 打赏
  • 举报
回复
Syntax

bSuccess = object.setData(sDataFormat, sData)

Parameters

sDataFormat Required.
String that specifies the format of the data to be transferred, using one of the following values:

Text Transfers data formatted as text.
URL Transfers data formatted as a URL.

sData Required.
String that specifies the data supplied by the source object. This information can be descriptive text, a source path to an image, or a URL for an anchor. When you pass "URL" as the sDataFormat parameter, you must use the sData parameter to provide the location of the object being transferred.

Return Value

Boolean. Returns one of the following possible values:

true The data was successfully added.
false The data was not added.
孟子E章 2002-05-30
  • 打赏
  • 举报
回复
没有html这个参数:

Text,URL

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧