Skip to content

karzanOnline/url-location

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KLocation

将输入的字符串使用正则匹配,模拟返回window.location的值

构建状态

Build Status

使用方法

<script src="./KLocation.js"></script>

or

npm install klocation

实例化:

KLocation("https://github.com?a=1&b=2")

/*Objcet{
    url:"https://github.com?a=1&b=2",
    host : "github.com",
    protocol : "https:",
    pathname : "/",
    port :  ''
    hostname : "github.com"
    }*/

方法:

getParam

获取url参数集合返回一个对象

KLocation(url).getParam() 

// 返回值
// {a:1,b:2}

getHost

获取url对应host

KLocation(url).getHost() 

// 返回值
// github.com

getProtocol

获取url对应协议

KLocation(url).getProtocol()

// 返回值
// https:

getPort

获取url对应端口

KLocation(url).getPort()

// 返回值
// ''

getPathname

获取url对应pathname

KLocation(url).getPathname()

// 返回值
// "/"

About

KLoction.js 模拟返回window.location的值

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published