简体   繁体   中英

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:

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.

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...

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.

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. This type of link has no use in Microsoft Word and it can be removed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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