<bdo id='kPbhf'></bdo><ul id='kPbhf'></ul>

<small id='kPbhf'></small><noframes id='kPbhf'>

    1. <tfoot id='kPbhf'></tfoot>
      <legend id='kPbhf'><style id='kPbhf'><dir id='kPbhf'><q id='kPbhf'></q></dir></style></legend>

    2. <i id='kPbhf'><tr id='kPbhf'><dt id='kPbhf'><q id='kPbhf'><span id='kPbhf'><b id='kPbhf'><form id='kPbhf'><ins id='kPbhf'></ins><ul id='kPbhf'></ul><sub id='kPbhf'></sub></form><legend id='kPbhf'></legend><bdo id='kPbhf'><pre id='kPbhf'><center id='kPbhf'></center></pre></bdo></b><th id='kPbhf'></th></span></q></dt></tr></i><div id='kPbhf'><tfoot id='kPbhf'></tfoot><dl id='kPbhf'><fieldset id='kPbhf'></fieldset></dl></div>
    3. 在浏览器中显示的html页面中找到一个句子并突出显示

      时间:2023-09-05
        <tbody id='3r87O'></tbody>

          <bdo id='3r87O'></bdo><ul id='3r87O'></ul>
          <tfoot id='3r87O'></tfoot>

            <i id='3r87O'><tr id='3r87O'><dt id='3r87O'><q id='3r87O'><span id='3r87O'><b id='3r87O'><form id='3r87O'><ins id='3r87O'></ins><ul id='3r87O'></ul><sub id='3r87O'></sub></form><legend id='3r87O'></legend><bdo id='3r87O'><pre id='3r87O'><center id='3r87O'></center></pre></bdo></b><th id='3r87O'></th></span></q></dt></tr></i><div id='3r87O'><tfoot id='3r87O'></tfoot><dl id='3r87O'><fieldset id='3r87O'></fieldset></dl></div>
              • <legend id='3r87O'><style id='3r87O'><dir id='3r87O'><q id='3r87O'></q></dir></style></legend>

                <small id='3r87O'></small><noframes id='3r87O'>

              • 本文介绍了在浏览器中显示的html页面中找到一个句子并突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用 asp.net mvc 来显示一个 .html 文档,我知道它包含什么.

                我的控制器中有这个方法:

                public ActionResult GetHtmlPage(字符串路径){return new FilePathResult(path, "text/html");}

                我有这个简单的视图:

                <代码>@{ViewBag.Title = "管理文档";}<h2>管理文档</h2>@Html.Action("GetHtmlPage", "myController", new { path = Model.documentPath })

                文档显示没有问题.但我想突出显示我知道它存在于文档某处的特定句子.

                我的意思是,我正在尝试实现一个 JavaScript 代码,也许是为了找到我想在文档中突出显示的特定句子并突出显示它!我在 JavaScript 中阅读了有关 window.find() 的信息,但我的 asp.net 解决方案似乎无法识别它.

                我正在使用 VS2015 企业版

                解决方案

                您可以使用 jQuery 用一些标签包装文本并应用您可能需要的任何自定义样式.假设您有以下标记:

                这是一些具体的句子</div>

                而你想要这样结束:

                这是<strong>一些具体的</strong>句子</div>

                您可以尝试使用 :contains 选择器来定位文本的所需部分,然后用一些标签将其包装起来:

                $("div:contains('some specific')").html(function(_, html) {return html.replace(/(some specific)/g, "<strong>$1</strong>");});

                这里有一个 示例小提琴.

                I'm using asp.net mvc to display a .html document that I know exactly what it contains.

                I have this method in my controller:

                public ActionResult GetHtmlPage(string path)
                {
                    return new FilePathResult(path, "text/html");
                }
                

                and I have this Simple view:

                @{
                ViewBag.Title = "ManageDocument";
                }
                <h2>ManageDocument</h2>
                @Html.Action("GetHtmlPage", "myController", new { path = Model.documentPath })
                

                The document is displayed with no problems. But i want to Highlight a specific sentence that I know it exists somewhere in the document.

                What I mean is, I'm trying to implement a JavaScript code maybe to find that specific sentence i want to highlight in the document and highlight it! I read about window.find() in JavaScript but my asp.net solution doesn't seem to recognize it.

                I'm using VS2015 Enterprise

                解决方案

                You could use jQuery to wrap the text with some tags and apply whatever custom styles you might need. Let's suppose that you have the following markup:

                <div>
                    This is some specific sentence
                </div>
                

                and you want to end up with this:

                <div>
                    This is <strong>some specific</strong> sentence
                </div>
                

                You could try the :contains selector to locate the desired portion of the text and then wrap it with some tags:

                $("div:contains('some specific')").html(function(_, html) {
                   return html.replace(/(some specific)/g, "<strong>$1</strong>");
                });
                

                And here's a sample fiddle.

                这篇关于在浏览器中显示的html页面中找到一个句子并突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:对齐复选框输入和 &lt;p&gt;标记在同一行 下一篇:如何在两次潜水之间将按钮放在顶部?

                相关文章

                    <bdo id='wF5Dd'></bdo><ul id='wF5Dd'></ul>
                  <i id='wF5Dd'><tr id='wF5Dd'><dt id='wF5Dd'><q id='wF5Dd'><span id='wF5Dd'><b id='wF5Dd'><form id='wF5Dd'><ins id='wF5Dd'></ins><ul id='wF5Dd'></ul><sub id='wF5Dd'></sub></form><legend id='wF5Dd'></legend><bdo id='wF5Dd'><pre id='wF5Dd'><center id='wF5Dd'></center></pre></bdo></b><th id='wF5Dd'></th></span></q></dt></tr></i><div id='wF5Dd'><tfoot id='wF5Dd'></tfoot><dl id='wF5Dd'><fieldset id='wF5Dd'></fieldset></dl></div>
                1. <small id='wF5Dd'></small><noframes id='wF5Dd'>

                2. <legend id='wF5Dd'><style id='wF5Dd'><dir id='wF5Dd'><q id='wF5Dd'></q></dir></style></legend>

                  <tfoot id='wF5Dd'></tfoot>