100分求一个读剪贴板的小问题

yaojian524 2007-11-08 02:54:30
System.Windows.Forms.IDataObject iData = System.Windows.Forms.Clipboard.GetDataObject();
if (iData.GetDataPresent(System.Windows.Forms.DataFormats.Html))
{
string strValue = (string)iData.GetData(System.Windows.Forms.DataFormats.Html);
}

这段代码我放到winform里没有问题,可以取出数据。但是放到web里“iData”取出来的就是“null”,为什么呢?
在web里应该怎么读剪贴板的值呢?不是text值,是要读html的编码。
...全文
107 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yaojian524 2007-11-08
  • 打赏
  • 举报
回复
谢谢 我找找看
lizhizhe2000 2007-11-08
  • 打赏
  • 举报
回复
用js获取添加到网页中.你可以搜索"javascript Dom"
cpio 2007-11-08
  • 打赏
  • 举报
回复
getData Method

--------------------------------------------------------------------------------

Retrieves the data in the specified format from the clipboard through the dataTransfer or clipboardData objects.

Syntax

sRetrieveData = object.getData(sDataFormat)
Parameters

sDataFormat Required. String that specifies one of the following data format values:
Text Retrieves data formatted as text.
URL Retrieves data formatted as a URL.


Return Value

String. Returns the data in the format retrieved from clipboard through the dataTransfer or clipboardData object. Depending on the information contained in setData, this variable can retrieve a path to an image, text, or an anchor URL.

Remarks

The getData method enforces cross-frame security and allows data transfers within the same domain only. To the user this means that dragging a selection between different security protocols, such as HTTP and HTTPS, will fail. In addition, dragging a selection between two instances of the browser with different security levels, where the first instance is set to medium and the second is set to high, will fail. Finally, dragging a selection into the browser from another drag-enabled application, such as Microsoft Word, also will fail.

To use the getData method to retrieve data from the clipboard within the oncopy or oncut event, specify window.event.returnValue=false within the event handler script.

Examples

yaojian524 2007-11-08
  • 打赏
  • 举报
回复
其次,取出来的文本,你是不是可以转换成HTML?

=============================================

我就是这个不知道怎么做
cxx1997 2007-11-08
  • 打赏
  • 举报
回复
首先,肯定是用JS来获取

其次,取出来的文本,你是不是可以转换成HTML?
yaojian524 2007-11-08
  • 打赏
  • 举报
回复
window.clipboardData.getData( "html");又报错
yaojian524 2007-11-08
  • 打赏
  • 举报
回复
js里用window.clipboardData.getData("text");可以取文本,但我想取html啊
yaojian524 2007-11-08
  • 打赏
  • 举报
回复
那我应该怎么做呢?
cxx1997 2007-11-08
  • 打赏
  • 举报
回复
web的代码是在WEB服务器上执行的,所以,你读的是服务器上的剪贴板的值

62,248

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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