10 examples of 'location href in jquery' in JavaScript

Every line of 'location href in jquery' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
37function redirectbasehref(el, responseText) {
38 var mo = responseText.match(/<base href="(\S+?)"/i);
39 if (mo.length === 2) {
40 return mo[1];
41 }
42 return location;
43}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

76function createHref(location) {
77 return history.createHref(resolveLocation(location));
78}
11function getLocation(url){
12 var search,
13 a = document.createElement('a'),
14 params = utils.serializeParam(me.queryCommandValue('serverparam')) || '';
15
16 a.href = url;
17 if (browser.ie) {
18 a.href = a.href;
19 }
20
21
22 search = a.search;
23 if (params) {
24 search = search + (search.indexOf('?') == -1 ? '?':'&')+ params;
25 search = search.replace(/[&]+/ig, '&');
26 }
27 return {
28 'port': a.port,
29 'hostname': a.hostname,
30 'path': a.pathname + search || + a.hash
31 }
32}
4function loc(href){
5 var a = document.createElement('a');
6 var self = {
7 replace: function(href) {
8 a.href = href;
9 Regular.util.extend(this, {
10 href: a.href,
11 hash: a.hash,
12 host: a.host,
13 fragment: a.fragment,
14 pathname: a.pathname,
15 search: a.search
16 }, true)
17 if (!/^\//.test(this.pathname)) this.pathname = '/' + this.pathname;
18 return this;
19 },
20 history: {
21 replaceState: function(obj, title, path){
22
23 self.replace(path)
24 // a.href = path
25 },
26 pushState: function(obj, title, path){
27 self.replace(path)
28 }
29 }
30 }
31 return (self).replace(href)
32}
194function getLocation(url) : URLLocation {
195 var parts = /([^\?]*)\/*(\??.*)/.exec(url);
196 return {
197 base: parts[1],
198 queryString: parts[2]
199 };
200}
231function after_setWindowLocation(win, url) {
232 goog.dom.safe.setLocationHref(win.location, url);
233}
32function getLocation( href ) {
33 if ( document ) {
34 const a = document.createElement( "a" );
35 a.href = href;
36 return a;
37 } else {
38 const match = href.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
39 return match && {
40 href : href,
41 protocol: match[1],
42 host : match[2],
43 hostname: match[3],
44 port : match[4],
45 pathname: match[5],
46 search : match[6],
47 hash : match[7]
48 }
49 }
50}
182function createHref(location) {
183 return createPath(location);
184}
131function addHashIfNeeded(href) {
132 if (sniffer.history) {
133 return href;
134 }
135 var index = href.indexOf('#');
136 if (index===-1) {
137 return href+'#';
138 }
139 return href;
140}
17function locationHashChanged () {
18 if (window.location.hash === '#all' || window.location.hash === '') {
19 showAll()
20 } else {
21 filterCategory(window.location.hash.substr(1))
22 }
23}

Related snippets