简体   繁体   中英

Stripping html tags out of a title using javascript

I have a Javascript function currently overriding a html display to allow longer titles to display over the programs replacement string rule which does work. The problem I am seeing though is even though it does work, the html tags are showing up in the title:

So in a folder structure it shows like this (which is correct): Aggregated Pricing Item Test - foo

but in the detail page title it is showing up like this after the script executes:

 Aggregated Pricing Item Test - <b>foo</b>

Is there anyway to change the existing javascript to either use or eliminate it displaying the html elements?

Here is the code we are using for the override:

 <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jSINI.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
    var doc_id = CallSINIMethod("GetValue",["SystemProperty","CurrentUserDocument", null]);
    var int_id = CallSINIMethod("GetValue",["DocumentProperty","ProductID", doc_id]);
    var prod_name = CallSINIMethod("GetValue",["ProductProperty","DisplayName", int_id]);
    $('div.areaTitle').text(prod_name);
    });
    </script> 

这是因为您正在使用text属性,它将完全显示您提供的内容,因此您需要将其更改为html以便正确显示。

$('div.areaTitle').html(prod_name);

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