如何将链接的 html 源复制到剪贴板并解析为 Lotus Notes 中的链接?

发布于 2024-08-03 01:18:44 字数 344 浏览 8 评论 0原文

如何将链接的 html 代码复制到剪贴板并将其解析为 Lotus Notes 中的链接?

例如,在 Javascript 中,将 StackOverFlow 放入剪贴板,然后将其解析为 Lotus Notes 中的链接,而写一封新电子邮件。它应该只在新消息中显示为 StackOverFlow 的链接。

我找到了一个函数window.clipboardData.setData("Text",link),但它只能将文本复制到剪贴板中。

有什么建议给我吗?

How do you copy the html code of a link to the clipboard and parse it as a link in Lotus Notes?

For example, in Javascript put <a href='http://www.stackoverflow.com'>StackOverFlow</a> into clipboard, and then parse it as a link in Lotus Notes while writing a new email. It should only show a link as StackOverFlow in new message.

I found a function window.clipboardData.setData("Text",link), but it can only copy the text into clipboard.

Any tips for me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

骄傲 2024-08-10 01:18:44

@Carlos 有基本的用户级方法来执行此操作,但似乎您想以编程方式执行此操作。我认为最有效的方法是执行诸如“粘贴链接”之类的操作:

  1. 访问剪贴板
  2. 将文本解析为基本 html 片段
  3. 将该片段保存到磁盘 将该
  4. html 导入

此处的富文本字段 有关如何访问剪贴板的示例

要将链接导入到笔记中,请根据您的操作构建一个基本的 HTML 文件,按照以下方式:

<html><body>
<a id="myLink" href="http://www.google.com">Google Site</a>
</body></html>

保存它,然后使用如下代码导入它:(

dim ws as New NotesUIWorkspace
dim d as NotesUIDocument
set d = ws.currentDocument

call d.import( "HTML File", "c:\foo.html" )

假设您将文件保存为“c:\foo.html”)。

根据您想要实现的具体目标以及您最满意的目标,您可能希望在 Notes 之外编写 HTML,然后仅让操作执行导入位。如果您采用这种方法,那么就不再需要使用剪贴板了。

请注意以下事项:

  • “NotesUIDocument.Import()”方法会在光标位于富文本(正文)字段中的任何位置注入 HTML 文件的内容。您需要将光标放在正确的位置。
  • 如果您将光标放在非富文本字段中,您可能会收到错误。
  • `NotesUIDocument.Import()` 方法镜像了菜单项 `File \ Import` 的功能,因此如果您不愿意,您甚至不必在 Notes 中编写任何代码。

@Carlos has the basic user-level way to do it but it seems you want to do this programattically. I think the most effective approach is to have an action such as "paste link" that:

  1. accesses the clipboard
  2. parses the text into a basic html fragment
  3. saves that fragment to disk
  4. imports that html into the rich text field

here's an example on how to get to the clipboard.

To import the link into notes, build a rudimentary HTML file from your action, along the lines of:

<html><body>
<a id="myLink" href="http://www.google.com">Google Site</a>
</body></html>

save it and then import it using code like:

dim ws as New NotesUIWorkspace
dim d as NotesUIDocument
set d = ws.currentDocument

call d.import( "HTML File", "c:\foo.html" )

(assuming you saved your file as "c:\foo.html").

Depending on what exactly you are trying to achieve and what you're most comfortable with, you may want to compose the HTML outside of Notes and just have the action do the import bit. If you take this approach then the need to play with the clipboard is gone.

Note the following:

  • the method `NotesUIDocument.Import()` injects the contents of the HTML file wherever the cursor is in the rich text (body) field. You need to have your cursor in the right place.
  • if you've got the cursor in a non-rich text field you will probably get an error.
  • the method `NotesUIDocument.Import()` mirrors the functionality of the menu item `File \ Import` so you don't even have to write any code in Notes if you don't want to.
傲影 2024-08-10 01:18:44

window.clipboardData 是 Internet Explorer 独有的功能。其他浏览器供应商将干预剪贴板视为一种安全威胁,并且可能非常烦人,因此它没有在 Firefox 中实现。

我知道跨浏览器执行此操作的唯一方法是使用 Flash 影片,您可以在此处找到更多相关信息:http://www.jeffothy.com/weblog/clipboard-copy/

如果您对仅支持 IE 感到满意,那么获取元素的完整外部 HTML 的方法 (不仅仅是innerHTML)将链接复制到另一个元素并获取那个元素的innerHTML。

javascript 看起来像这样(抱歉,它未经测试)

var newEl = myLink.cloneNode()
var div = document.createElement('div');
div.appendChild(newEl);
var outerHTML = div.innerHTML;    // <-- this is the variable you want.

window.clipboardData is an Internet Explorer only feature. Other browser vendors view meddling with the clipboard as a security threat and potentially really really annoying so it isn't implemented in Firefox, for example.

The only way I know to do it cross-browser is to use a Flash movie, and you can find out more about that here: http://www.jeffothy.com/weblog/clipboard-copy/

If you're happy with supporting IE only, then the way to get the full outer HTML of an element (not just the innerHTML) would be to duplicate the link into another element and get the innerHTML of that element.

The javascript looks something like this (sorry, it's untested)

var newEl = myLink.cloneNode()
var div = document.createElement('div');
div.appendChild(newEl);
var outerHTML = div.innerHTML;    // <-- this is the variable you want.
落日海湾 2024-08-10 01:18:44

要在 Lotus Notes 电子邮件中创建链接,您必须:

  1. 编写链接的文本 示例:Stackoverflow
  2. 选择文本
  3. 单击创建 -> 热点 -> 链接热点...
  4. 在值字段中输入 url

这是用于 Notes 7. 不确定是 Notes 8 还是 8.0.2 在工具栏上添加了一个按钮以方便执行此操作。

希望这有帮助

To create a link in a Lotus Notes email you have to:

  1. Write the Text for the link example: Stackoverflow
  2. Select the text
  3. Click Create->Hotspot->Link Hotspot...
  4. Enter the url in the Value field

This is for Notes 7. Not sure if it was Notes 8 or 8.0.2 where they added a button on the toolbar to make it easy to do this.

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文