zoukankan      html  css  js  c++  java
  • 工具函数

    工具函数

    • 获取url hash参数
    function getParameter(n) {
        var m = window.location.hash.match(new RegExp('(?:#|&)' + n + '=([^&]*)(&|$)')),
            result = !m ? '' : decodeURIComponent(m[1])
        return result ||getParameterByName(n)
    }
    
    function getParameterByName(name, url) {
        if (!url) url = window.location.href
        name = name.replace(/[[]]/g, "\$&")
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url)
        if (!results) return null
        if (!results[2]) return ''
        return decodeURIComponent(results[2].replace(/+/g, " "))
    }
    
    • JSONP跨域
    function loadScript(src, callback){
        var s,
            r,
            t
        r = false
        s = document.createElement('script')
        s.type = 'text/javascript'
        s.src = src
        s.onload = s.onreadystatechange = function() {
            //console.log( this.readyState ); //uncomment this line to see which ready states are called.
            if ( !r && (!this.readyState || this.readyState == 'complete') )
            {
                r = true
                callback()
            }
        }
        t = document.getElementsByTagName('script')[0]
        t.parentNode.insertBefore(s, t)
    }
    
  • 相关阅读:
    JAVA-类加载机制(2)-类加载的过程
    JAVA-类加载机制(1)-生命周期
    StarUML-详解
    JMS-mq-发布/订阅
    JMS-mq-点对点
    Spring-Transcation
    Session-Hibernate
    Session
    Git配置
    Maven配置
  • 原文地址:https://www.cnblogs.com/gongxiansheng/p/11259296.html
Copyright © 2011-2022 走看看