10 examples of 'jquery get href' in JavaScript

Every line of 'jquery get href' 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

214function showHref(element) {
215 if (tempHrefs[element.attr('id')]) {
216 element.attr('href', tempHrefs[element.attr('id')]);
217 }
218}
196resolveHref(el) {
197 if (!el) {
198 return null;
199 }
200 const closestHrefEl = el.closest('[href]');
201 return closestHrefEl ? closestHrefEl.getAttribute('href') : null;
202}
52function getHref(element) {
53 try {
54 return element.href || null;
55 } catch (x) {
56 // IE throws a security exception for urls including username/password:
57 // http://user:password@example.com/
58 return null;
59 }
60}
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}
27pushHref (href) {
28 window.location.hash = href
29}
188function extract_orig(href) {
189 if (!href) {
190 return "";
191 }
192
193 // proxy mode: no extraction needed
194 if (!wb_replay_prefix) {
195 return href;
196 }
197
198 href = href.toString();
199
200 var index = href.indexOf("/http", 1);
201
202 // extract original url from wburl
203 if (index > 0) {
204 href = href.substr(index + 1);
205 } else {
206 index = href.indexOf(wb_replay_prefix);
207 if (index >= 0) {
208 href = href.substr(index + wb_replay_prefix.length);
209 }
210 if ((href.length > 4) &&
211 (href.charAt(2) == "_") &&
212 (href.charAt(3) == "/")) {
213 href = href.substr(4);
214 }
215
216 if (!starts_with(href, "http")) {
217 href = HTTP_PREFIX + href;
218 }
219 }
220
221 // remove trailing slash
222 if (ends_with(href, "/")) {
223 href = href.substring(0, href.length - 1);
224 }
225
226 return href;
227}
21function looksLikeHref(value) {
22 return !!value.match(/^https?:\/\/[^\/]+\//);
23}
43function SetBaseHRef( baseHref )
44{
45 var eBase = document.createElement( 'BASE' ) ;
46 eBase.href = baseHref ;
47
48 var eHead = document.getElementsByTagName( 'HEAD' )[0] ;
49 eHead.appendChild( eBase ) ;
50}
80function href(index) {
81 index = index.toLowerCase();
82 if (HTTP_SPECS.indexOf(index) > -1) {
83 return "https://httpwg.org/specs/" + index + ".html";
84 }
85 return "https://tools.ietf.org/html/" + unpad(index);
86}

Related snippets