简体   繁体   English

使用JavaScript在MS Word中复制代码段?

[英]Copy a code snippet in MS Word using JavaScript?

I've come across a Word document that includes sections of example code, all of which being preceded by hyperlinks called "Copy" with the following address format: 我遇到了一个Word文档,其中包含示例代码的各个部分,所有这些代码示例之前都带有以下地址格式的名为“复制”的超链接:

javascript:CodeSnippet_CopyCode('CodeSnippetContainerCode_538898d8-038f-4f82-9a2d-a558335289ae');

My question is, what in the world is this trying to do, and why isn't it working? 我的问题是,在世界上这是什么要做的,为什么不工作?

I'm assuming it should be copying the code snippets, but the result of Ctrl+Clicking the links is a security notice (clicked to allow) and then the IE View Downloads window shows up. 我假设它应该复制代码段,但是Ctrl +单击链接的结果是一个安全通知(单击以允许),然后显示IE View Downloads窗口。

Between my not really knowing javascript and all the alphanumeric garbage confusing my efforts to understand the syntax, I can't make heads or tails of this... 在我不太了解javascript和所有字母数字垃圾之间,使我难以理解语法,我对此无能为力。

This is the Javascript command that is included in some websites such as MSDN to allow you to copy code snippets from the website to the clipboard with one click. 这是某些网站(例如MSDN)中包含的Javascript命令,允许您一键将代码段从网站复制到剪贴板。

When the original author copied the code to the word document he must of copied the link the links which include that Javascript command as well by a mistake. 当原始作者将代码复制到word文档时,他必须复制链接,并且错误地包含了该Javascript命令的链接。 This type of link has no use in Microsoft Word and it can be removed. 这种类型的链接在Microsoft Word中没有用,可以将其删除。

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

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