6 examples of 'javascript redirect to relative url' in JavaScript

Every line of 'javascript redirect to relative 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
68function redirect(text = null) {
69 if (text == null) {
70 text = document.querySelector('#search-box').value;
71 }
72 location.href = '/?q=' + encodeURIComponent(text);
73}
50function redirect()
51{
52if (second < 0)
53{
54
55location.href = '/sba';
56} else
57{
58if (navigator.appName.indexOf("Explorer") > -1)
59{
60document.getElementById('totalSecond').innerText = second--;
61} else
62{
63document.getElementById('totalSecond').textContent = second--;
64}
65}
66}
310function redirect(url) {
311 var
312 hash_pos = url.indexOf('#'),
313 query_pos = url.indexOf('?'),
314 hash = '';
315 if (hash_pos >=0 ) {
316 hash = url.substring(hash_pos);
317 url = url.substring(0, hash_pos);
318 }
319 url = url + (query_pos >= 0 ? '&' : '?') + 't=' + new Date().getTime() + hash;
320 console.log('redirect to: ' + url);
321 location.assign(url);
322}
519function redirectTo(url) {
520 setBubbleText(t('redirecting', { hostName: util.hostNameFromUri(url) }));
521 addClass(elements.bubble, 'one-line');
522 setTimeout(function() {
523 document.location = url;
524 }, 500);
525}
62function redirect(url, param) {
63 if (!url)
64 return;
65
66 var _param = param || {};
67 var formId = 'redirectForm' + new Date().getTime();
68 var formHtml = "".format(formId, url);
69
70 Object.keys(_param).forEach(function (aProperty) {
71 if (_param[aProperty]) {
72 formHtml += "".format(aProperty, _param[aProperty].toString());
73 }
74 });
75
76 formHtml += '';
77 $(formHtml).appendTo('body');
78
79 $('#' + formId).submit();
80}
47function redirectBrowserTo(url)
48{
49 $window.location.href = url;
50}

Related snippets