过滤html标记 以及 返回顶部

//过滤<pre > </pre>
str = Regex.Replace(str, @"\<(pre)[^>]*>|<\/pre>", "", RegexOptions.IgnoreCase);
                                                   
//返回顶部
var BROWSER = {};
var USERAGENT = navigator.userAgent.toLowerCase();
browserVersion({ 'ie': 'msie', 'firefox': '', 'chrome': '', 'opera': '', 'safari': '', 'mozilla': '', 'webkit': '', 'maxthon': '', 'qq': 'qqbrowser' });
if (BROWSER.safari) {
BROWSER.firefox = true;
}
BROWSER.opera = BROWSER.opera ? opera.version() : 0;
if (BROWSER.ie) {

document.documentElement.addBehavior("#default#userdata");
}

function browserVersion(types) {
var other = 1;
for (i in types) {
var v = types[i] ? types[i] : i;
if (USERAGENT.indexOf(v) != -1) {
var re = new RegExp(v + '(\\/|\\s)([\\d\\.]+)', 'ig');
var matches = re.exec(USERAGENT);
var ver = matches != null ? matches[2] : 0;
other = ver !== 0 && v != 'mozilla' ? 0 : other;
} else {
var ver = 0;
}
eval('BROWSER.' + i + '= ver');
}
BROWSER.other = other;
}
//ie6下滚动问题
function ScrollTopByIE6() {
    var isie6 = window.XMLHttpRequest ? false : true;
    if (isie6)
        $('scrolltop').style.position = 'absolute';
}

window.onscroll = function() {
   //ie6下滚动问题
    ScrollTopByIE6();
if ($('scrolltop') != null) {
if (document.documentElement.scrollTop == 0 && document.body.scrollTop == 0)
$('scrolltop').style.display = 'none';
else {
if (BROWSER.ie && BROWSER.ie < 7) {
var viewPortHeight
= parseInt(document.documentElement.clientHeight);
var scrollHeight = parseInt(document.body.getBoundingClientRect().top);
$('scrolltop').style.top = viewPortHeight - scrollHeight - 60 + 'px';
}
$('scrolltop').style.display
= 'block';
}
}
}

function setScrollToTop(id) {
window.scroll(0, 0);
$(id).style.display
== '' ? 'none' : '';
}
<style
>
.scrolltop
{
background-image: url(images/bbsdetails/gotop.gif);
background-repeat: no-repeat;
background-position: 0 0;
display: none;
height: 58px;
overflow: hidden;
18px;
line-height: 140px;
position: fixed;
bottom: 120px;
}
</style>
<a id="scrolltop" href="javascript:;" style="left: 1200px;" class="scrolltop" onclick="setScrollToTop(this.id);"> TOP</a>



原文地址:https://www.cnblogs.com/jonhson/p/2201869.html