10 examples of 'get site url in jquery' in JavaScript

Every line of 'get site url 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
92function getWebsiteURL()
93{
94 var url = window.location.toString()+'/'; // example: http://mydomain.com/params/etc/
95 var idx1 = url.indexOf('/');
96 var idx2 = url.indexOf('/', idx1+3); // find the 3rd forward-slash
97 url = url.substr(0, idx2);
98 return url; // without "/" => http://mydomain.com
99}
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

1export default function getBaseUrl() {
2 return getQueryStringParameterByName("useMockApi")
3 ? "http://localhost:3001/"
4 : "/";
5}
62function __getURL(url) {
63 url = __getURLNoCDN(url);
64 // only relative urls
65 if (__paths.CDN && /^\\\/[^\\\/]/.test(url)) {
66 url = __paths.CDN + url;
67 } else if (__paths.S3CDN) {
68 url = url.replace(__paths.S3BaseUrl, __paths.S3CDN);
69 }
70 return url;
71}
135function getBaseURL(url) {
136 var baseURL = "";
137 if ( inURL(url, '_design') ) {
138 if (inURL(url, '_rewrite')) {
139 var path = url.split("#")[0];
140 if (path[path.length - 1] === "/") {
141 baseURL = "";
142 } else {
143 baseURL = '_rewrite/';
144 }
145 } else {
146 baseURL = '_rewrite/';
147 }
148 }
149 return baseURL;
150}
208function getUrl(url) {
209 return url && url.replace(/#.*$/, '');
210}
48export function getURL() {
49 const { href } = window.location;
50 const origin = getLocationOrigin();
51 return href.substring(origin.length);
52}
7export function getUrl(url) {
8 return config.base + url;
9}
106function getScriptUrl(prefix, scriptName) {
107 return prefix + scriptName;
108}
41function getUrl(page) {
42 let url = PREFIX + '/';
43 if (page.directory) {
44 url += page.directory + '/';
45 }
46 return url + page.file;
47}
6function baseUrl(permalink) {
7 var siteUrl = $('body').data('baseurl');
8 var permalink = permalink || '';
9
10 return siteUrl + permalink;
11}

Related snippets