7 examples of 'window url' in JavaScript

Every line of 'window 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
231function after_setWindowLocation(win, url) {
232 goog.dom.safe.setLocationHref(win.location, url);
233}
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

7export function opensInWindow(url: string) {
8 return whitelist[normalizeURL(url)];
9}
11export function windowOpen(url, { name, height = 400, width = 550 }) {
12 const left = (window.outerWidth / 2)
13 + (window.screenX || window.screenLeft || 0) - (width / 2);
14 const top = (window.outerHeight / 2)
15 + (window.screenY || window.screenTop || 0) - (height / 2);
16
17 const config = {
18 height,
19 width,
20 left,
21 top,
22 location: 'no',
23 toolbar: 'no',
24 status: 'no',
25 directories: 'no',
26 menubar: 'no',
27 scrollbars: 'yes',
28 resizable: 'no',
29 centerscreen: 'yes',
30 chrome: 'yes',
31 };
32
33 return window.open(
34 url,
35 platform.name === 'IE' && parseInt(platform.version, 10) < 10 ? '' : name,
36 Object.keys(config).map(key => `${key}=${config[key]}`).join(', ')
37 );
38}
45function openWindow(url) {
46 return new Promise(resolve => {
47 const win = window.open(url, '_blank');
48 add_completion_callback(() => win.close());
49 window.onmessage = e => {
50 assert_equals(e.data, 'LOADED');
51 resolve(win);
52 };
53 });
54}
600setWindowLocationUrl: function setWindowLocationUrl (url) {
601 var windowLocation = this._windowLocation || window.location; // Allow stubbing for unit testing
602
603 // Prefer assign(), but some devices don't have this function.
604 if (typeof windowLocation.assign === 'function') {
605 windowLocation.assign(url);
606 } else {
607 windowLocation.href = url;
608 }
609},
47get url() {
48 return this.toJSON().url
49}
13function with_window(url, name) {
14 return new Promise(function(resolve) {
15 var child = window.open(url, name);
16 window.onmessage = () => {resolve(child)};
17 });
18}

Related snippets