简体   繁体   English

从 Chrome 开发者工具中复制 HTML 元素 object

[英]Copying the HTML element object form Chrome developer tools

I am trying to copy the HTML element object from Chrome developer tools.我正在尝试从 Chrome 开发人员工具中复制 HTML 元素object When I hover my mouse over the HTML element, then it shows me the element as an object.当我将鼠标 hover 放在 HTML 元素上时,它会显示该元素为 object。

When I inspect it in the console then it shows me the element rendered as HTML.当我在控制台中检查它时,它会显示呈现为 HTML 的元素。

If I then do a copy(this.input) then it copies the rendered HTML (not the actual object)如果我然后做一个 copy(this.input) 然后它复制呈现的 HTML (不是实际对象)

How do I get the object ?如何获得object

在此处输入图像描述

From the documentation , copy specifically copies a string representation: 文档中copy特别复制一个字符串表示形式:

copy(object) copies a string representation of the specified object to the clipboard. copy(object)将指定对象的字符串表示形式复制到剪贴板。

(my emphasis) (我的重点)

Copying the actual object would require that your clipboard contain data from the DOM memory of the browser. 复制实际对象将需要剪贴板包含浏览器DOM内存中的数据。 Typically that's not possible. 通常这是不可能的。 Clipboards can contain various standard formats (text, obviously; rich text sometimes; the locations of files; image data in various formats; etc.), but I don't believe it's possible to copy the actual object data from the DOM into your clipboard. 剪贴板可以包含各种标准格式(很明显是文本;有时是富文本;文件的位置;各种格式的图像数据;等等),但是我认为不可能将DOM中的实际对象数据复制到剪贴板中。 (If it is possible, which I doubt, I don't see anything in the Command Line API that does it.) The standard representation for a DOM element is, of course, HTML, so it makes sense for Chrome to copy that to the clipboard, even though of course converting to HTML is lossy. (我怀疑,如果有可能的话,我在命令行API中看不到任何东西。)DOM元素的标准表示当然是HTML,因此Chrome将其复制到剪贴板,即使转换为HTML当然是有损的。

There is a workaround: https://developer.chrome.com/docs/devtools/dom/#current , try use $0有一个解决方法: https://developer.chrome.com/docs/devtools/dom/#current ,尝试使用$0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM