本文介绍了在网页中显示html内容也在相同的html文本中应用指定的html样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 * I am working on a assignment related to comparing two text content.*$ Following is sample output I am having :(Content can be of any type javascript html css .java .php .c# etc....) $ Following symbols denote : #~#~# - Content delete Start #~##~# -Content delete Stop #~~# - Content Insert Start #~~~# -Content Insert Stop---------- Albert is a good boy <title>Compare this file *#~~# content #~~~#* with previous file contents.peter *#~#~#Content Removed #~##~#* *#~~#<center>#~~~# *#~#~# you are bad #~##~#* This is a text-------------------- /* .diff-checker .diff-output .diff-line-modified .diff-chunk-inserted { background: #9F9; } .diff-checker .diff-output .diff-line-modified .diff-chunk-removed { background: #F88; }*/ Based on above denotation,After Parsing. I have following two versions which I want to display in Tabular format by applying above style in modified contents: ---------- Version 1 ----------$/* Albert is a good boy <title>Compare this file with previous file contents.peter <span class='diff-chunk-removed'> Content Removed </span>* *<span class='diff-chunk-removed'> </table> </span>* This is a text*/----------Version 2//Second version will highlight inserted content----------/* Albert is a good boy <title>Compare this file *<span class='diff-chunk-inserted'> content </span>* with previous file contents.peter *<span class='diff-chunk-inserted'> <center> </span>* This is a text*/ I tried several ways to achieve the expected output by displaying the content in jsp or javascript in tabular format . But I failed to do so because I try to display the content as TEXT then mentioned style is not getting applied and when I try to display them as HTML then html text is been rendered on page.Following is block of javascript code I wrote to insert the data into table: /* var tr = table.insertRow(-1); var td1 = document.createElement('td'); td1.align='center'; td1.innerHTML = col1; var td2 = document.createElement('td'); td2.align='center'; td2.innerText = returnString; tr.appendChild(td1); tr.appendChild(td2);*/ Thanks For Solution .推荐答案 这篇关于在网页中显示html内容也在相同的html文本中应用指定的html样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-15 19:41