• 过滤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>



  • 相关阅读:
    存储过程生成POCO
    Asp.net MVC4与Razor呈现图片的扩展
    Html5中新input标签与Asp.net MVC应用程序
    HTML5上传文件显示进度
    JQuery图表插件之Flot
    用Html5与Asp.net MVC上传多个文件
    TSQL列出最后访问的存储过程
    Asp.net MVC 限制一个方法到指定的Submit按钮
    VisualStudio2012轻松把JSON数据转换到POCO的代码
    Apache Tika源码研究(三)
  • 原文地址:https://www.cnblogs.com/jonhson/p/2201869.html
Copyright © 2020-2023  润新知