10 examples of 'popup window javascript onclick' in JavaScript

Every line of 'popup window javascript onclick' 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
4function popUp(URL) {
5 day = new Date();
6 id = day.getTime();
7 eval("page = window.open(URL, 'xqdoccode', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=400,left = 412,top = 334');")
8 page.focus();
9}
21function popup(mylink, windowname)
22{
23 if (! window.focus)
24 {
25 return true;
26 }
27 var href;
28 if (typeof(mylink) == 'string')
29 {
30 href=mylink;
31 window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
32 return false;
33 }
34 else
35 {
36 href=mylink.href;
37 window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
38 return false;
39 }
40}
26function openPopup (href) {
27 if (window.popup && !window.closed) window.popup.close();
28 var width = 1000;
29 var height = 800;
30 var x = (screen.width / 2) - (width / 2);
31 var y = (screen.height / 2) - (height / 2);
32 var win = new BrowserWindow({
33 width, height, x, y,
34 center: true,
35 autoHideMenuBar: true,
36 webPreferences: {
37 webSecurity: true,
38 nodeIntegration: false,
39 plugins: true,
40 },
41 });
42 win.id = 'popup';
43 win.loadURL(href);
44 window.win = win;
45 /*
46 nw.Window.open('app/popup.html?href=' + encodeURIComponent(href), {x: left, y: top, width: w, height: h},
47 function (win) {
48 window.popup = win.window;
49
50 // do not open the window and open it in external browser
51 win.on('new-win-policy', function (frame, url, policy) {
52 policy.ignore();
53 nw.Shell.openExternal(url);
54 });
55
56 win.window.id = 'popup';
57 win.window.config = App.config;
58 win.focus();
59 });
60 */
61}
1export default function popup(url, width = 800, height = 600, name = '') {
2 const left = (window.screen.width - width) / 2;
3 const top = (window.screen.height - height) / 2;
4 // const left = (window.screen.availWidth - width) / 2;
5 // const top = (window.screen.availHeight - height) / 2;
6 const defaults = 'directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no';
7 const params = `width=${width},height=${height},top=${top},left=${left},${defaults}`;
8 const win = window.open(url, name, params);
9 if (win === null || typeof win === 'undefined') {
10 return false;
11 }
12 if (window.focus) {
13 win.focus();
14 }
15 return true;
16}
9function popup(url) {
10 newwindow = window.open(url, 'name', 'height=400,width=400,menubar=false,resizable=false,scrollbars=false, status=false, titlebar=false, toolbar=false');
11 if (window.focus) { newwindow.focus() }
12 return false;
13}
1export function windowPopup(url: string, width: number, height: number) {
2 // Calculate the position of the popup so
3 // it’s centered on the screen.
4 var left = screen.width / 2 - width / 2,
5 top = screen.height / 2 - height / 2;
6 window.open(
7 url,
8 '',
9 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=' +
10 width +
11 ',height=' +
12 height +
13 ',top=' +
14 top +
15 ',left=' +
16 left
17 );
18}
315function windowPopup(url, width, height) {
316 var left = screen.width / 2 - width / 2,
317 top = screen.height / 2 - height / 2;
318 window.open(url, "", "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);
319}
141function openPopup(urlStr,windowName){
142 var wWidth = 900;
143 if(document.getElementById('maintable').offsetWidth){
144 wWidth = document.getElementById('maintable').offsetWidth*1.05;
145 }
146 else if(document.body.offsetWidth){
147 wWidth = document.body.offsetWidth*0.9;
148 }
149 newWindow = window.open(urlStr,windowName,'scrollbars=1,toolbar=1,resizable=1,width='+(wWidth)+',height=600,left=20,top=20');
150 if (newWindow.opener == null) newWindow.opener = self;
151 return false;
152}
1function popUp(url, title, w, h) {
2 var externalLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
3 var externalTop = window.screenTop != undefined ? window.screenTop : screen.top;
4
5 width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
6 height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
7
8 var left = ((width / 2) - (w / 2)) + externalLeft;
9 var top = ((height / 2) - (h / 2)) + externalTop;
10 var newWindow = window.open(url, title, 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
11
12 if (window.focus) {
13 newWindow.focus();
14 }
15 }
1function openPopup (url, width) {
2 var left, top, height,
3 screenLeft = screen.availLeft || 0,
4 bordersWidth = 8;
5 // if browser window is in the right half of screen, place new window on left half
6 if (window.screenX - screenLeft - bordersWidth * 1.5 > width) {
7 left = window.screenX - width - bordersWidth * 1.5;
8 // if browser window is in the left half of screen, place new window on right half
9 } else if (window.screenX + window.outerWidth + width + bordersWidth * 1.5 < screenLeft + screen.availWidth) {
10 left = window.screenX + window.outerWidth + bordersWidth;
11 // if screen is small or browser window occupies whole screen, place new window on top of current window
12 } else {
13 left = window.screenX + window.outerWidth / 2 - width / 2;
14 if (left < 0) {
15 left = 0;
16 }
17 }
18 top = window.screenY;
19 height = window.innerHeight;
20 var features = 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top;
21 features += ',resizable,scrollbars';
22 // to open single instance replace null with some string
23 window.open(url, null, features)
24 .focus();
25}

Related snippets