如何在CefSharp.LoadHtml中添加超链接?

问题描述 投票:2回答:1

现在有一个解决这个问题的方法,这里的代码对我有用:

chrome.LoadHtml(@"<html>
        <center><h1>New tab</h1></center>
        <center><a href=""https://youtube.com"">YouTube</a>, </center>
        <center><a href=""https://google.com"">Google</a></center>
        <center><a href=""https://github.com"">Github</a></center>
    </html>");

如何在CefSharp.LoadHtml中添加超链接?我一直在Visual Studio 2017中得到语法错误',',并且在添加逗号之后,youtube.com这样的链接仍然没有工作,所以我尝试了https://并且令我惊讶的是,它在发表评论之后做了一切。我做了一些研究,似乎目前没有其他人有这个问题。

我是CefSharp的新手,并在互联网上阅读了一些教程。这是我正在尝试的新页面页面。

chrome.LoadHtml("<html><center><h1>New tab</h1></center><center><a href="youtube.com">YouTube</a>, </center><center><a href="google.com">Google</a></center><center><a href="github.com">Github</a></center></html>");
c# cefsharp chromium-embedded
1个回答
2
投票

尝试这样的事情:

chrome.LoadHtml(
    @"<html>
        <center><h1>New tab</h1></center>
        <center><a href=""https://youtube.com"">YouTube</a></center>
        <center><a href=""https://google.com"">Google</a></center>
        <center><a href=""https://github.com"">Github</a></center>
    </html>");

它使用Verbatim String Literal,它允许您使用多行标记,就像大自然一样。双引号是VSL逃避双引号的方式。

© www.soinside.com 2019 - 2024. All rights reserved.