10 examples of 'javascript call url' in JavaScript

Every line of 'javascript call url' 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
64function _getLoadUrl(code) {
65 return this.contextPath + 'workflow/flow/define/viewxml/'+ code +'/000';
66}
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

106function getScriptUrl(prefix, scriptName) {
107 return prefix + scriptName;
108}
111function getScriptUrl(script) {
112 var url = script.src;
113 if (url) {
114 // Normalize package: urls
115 var index = url.indexOf('packages/');
116 if (index == 0 || (index > 0 && url[index - 1] == '/')) {
117 url = "package:" + url.slice(index + 9);
118 }
119 return url;
120 } else {
121 // TODO(sigmund): investigate how to eliminate the warning in Dartium
122 // (changing to text/javascript hides the warning, but seems wrong).
123 return "data:application/dart;base64," + window.btoa(script.textContent);
124 }
125}
1function js(jsURL) {
2 let bundleUrl = weex.config.bundleUrl
3 let baseURL = bundleUrl.substring(0, bundleUrl.lastIndexOf("/"))
4 //是否在同级目录,若不在,则需要以下处理
5 let flag = jsURL.indexOf('../') !== -1
6 if (flag) {
7 let arr = jsURL.split('../')
8 for (let index = 0; index < arr.length - 1; index++) {
9 baseURL = baseURL.substring(0, baseURL.lastIndexOf('/'))
10 }
11 jsURL = arr[arr.length - 1]
12 }
13 return baseURL + '/' + jsURL
14}
64function getJsCode(url) {
65 return unescape(url.substr(11));
66}
305function generateScriptDataUrl(script) {
306 var scriptContent = generateScriptContent(script);
307 return 'data:text/javascript;charset=utf-8,' + encodeURIComponent(scriptContent);
308}
227function getScript(url, success) {
228
229 var script = document.createElement('script');
230 script.type = 'text/javascript';
231 script.async = true;
232 script.src = url;
233
234 var head = document.getElementsByTagName('script')[0],
235 done = false;
236
237 head.parentNode.insertBefore(script, head);
238
239 script.onload = script.onreadystatechange = function() {
240
241 if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
242
243 // Callback
244 success();
245 script.onload = script.onreadystatechange = null;
246 done = true;
247
248 };
249
250 };
251
252};
15function getScript(url, success) {
16 var script = document.createElement('script');
17 var head = document.getElementsByTagName('head')[0],
18 done = false;
19 script.src = url;
20 // Attach handlers for all browsers
21 script.onload = script.onreadystatechange = function() {
22 if (!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) {
23 done = true;
24 // callback function provided as param
25 success();
26 script.onload = script.onreadystatechange = null;
27 head.removeChild(script);
28 };
29 };
30 head.appendChild(script);
31}
293function this_get_URL(url, callback, post_data, get_URL_options, charset) {
294 if (Array.isArray(url) && !post_data && !get_URL_options) {
295 // this.get_URL([ url, post_data, get_URL_options ])
296 post_data = url[1];
297 get_URL_options = url[2];
298 url = url[0];
299 }
300
301 // console.trace(url);
302 url = this.full_URL(url);
303
304 if (get_URL_options === true) {
305 // this.get_URL(url, callback, post_data, true)
306 get_URL_options = Object.assign({
307 error_retry : this.MAX_ERROR_RETRY
308 }, this.get_URL_options);
309 } else if (library_namespace.is_Object(get_URL_options)) {
310 // this.get_URL(url, callback, post_data, get_URL_options)
311 var headers = Object.assign(Object.create(null),
312 this.get_URL_options.headers, get_URL_options.headers);
313 get_URL_options = Object.assign(Object.create(null),
314 this.get_URL_options, get_URL_options);
315 get_URL_options.headers = headers;
316 } else {
317 // assert: !get_URL_options === true
318 get_URL_options = this.get_URL_options;
319 }
320 // console.log(get_URL_options);
321
322 // callback(result_Object, error)
323 get_URL(url, callback && callback.bind(this)
324 || library_namespace.null_function, charset || this.charset,
325 post_data, get_URL_options);
326}
18function jsToUrl(path, js) {
19 var url = urls[path];
20 if (url) window.URL.revokeObjectURL(url);
21 var blob = new Blob([js], { type: "application/javascript" });
22 return (urls[path] = window.URL.createObjectURL(blob));
23}

Related snippets