SyntaxbSuccess = object.setData(sDataFormat, sData)ParameterssDataFormat 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 ValueBoolean. Returns one of the following possible values:true The data was successfully added. false The data was not added.
SyntaxbSuccess = object.setData(sDataFormat, sData)ParameterssDataFormat 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 ValueBoolean. Returns one of the following possible values:true The data was successfully added. false The data was not added.
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.SyntaxbSuccess = object.setData(sDataFormat, sData)ParameterssDataFormat 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.
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 ValueBoolean. Returns one of the following possible values:true The data was successfully added.
false The data was not added.
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 ValueBoolean. Returns one of the following possible values:true The data was successfully added.
false The data was not added.
上面说:
setData(format,data)
返回值Boolean
存储字符串数据格式是以下之一:Text,URL,File,HTML,Image。对非文本数据格式,数据必须是字符串,它必须指定到当前内容的路径或者URL。
原来感觉这本书还不错,怎么犯这种错误?要不就是我理解错了,到底怎么回事?
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.
clipboardData.setData("Text","test<br>test");将数据复制到剪贴板
用clipboardData.getData("text"),贴上去后是直接将html标记也显示出来了
成了这样
test<br>test
而不是我想要的
test
test该怎么办?
可我只是举个例子,我实际想插入的是
<img src="aaa.jpg" alt="gggg" align="left">
这怎么办?
<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>
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>
demo.focus();
就是没想出用这个来~~~~~~~~