Onclick Open Window and Specific Size

onclick open window and specific size

<a href="/index2.php?option=com_jumi&fileid=3&Itemid=11"
onclick="window.open(this.href,'targetWindow',
`toolbar=no,
location=no,
status=no,
menubar=no,
scrollbars=yes,
resizable=yes,
width=SomeSize,
height=SomeSize`);
return false;">Popup link</a>

Where width and height are pixels without units (width=400 not width=400px).

In most browsers it will not work if it is not written without line breaks, once the variables are setup have everything in one line:

<a href="/index2.php?option=com_jumi&fileid=3&Itemid=11" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=SomeSize,height=SomeSize'); return false;">Popup link</a> 

How to create popup new window browser with small size

You can set height and width.

window.open("http://www.w3schools.com", "", "width=200,height=100");

To set position center.

var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;

var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;

var left = ((width / 2) - (w / 2)) + dualScreenLeft;
var top = ((height / 2) - (h / 2)) + dualScreenTop;

window.open("http://www.w3schools.com", "", "width=200,height=100, top=' + top + ', left=' + left");

Using JavaScript to open a window to a specific size

All the window options go in one string:

<div class="button" onclick="window.open('http://google.com', '_blank', 'width=600, height=600');return false;"></div>

I'm trying to open a window in a certain size?

<a href="http://wizs.com/listen-now-test/" target="_blank" onclick="window.open('http://wizs.com/listen-now-test/', 'myWin', 'toolbar=no, directories=no, location=no, status=yes, menubar=no, resizable=no, scrollbars=yes, width=300, height=200'); return false">
<img src="http://test.wizs.com/wp-content/uploads/2016/06/9.png">
</a>

There is no need for two distinct <a> tags. You may also want to disable the scrollbars in your popup window (scrollbars=no).

onClick to open window without fixed size

The 3rd paramter to window.open also controls the new window's "features". See https://developer.mozilla.org/de/docs/DOM/window.open

Available features:

menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes

Use resizable=yes.

how to size a window created in HTML with window.open to full width of the monitor and limit the height

You can access your monitor size with window.screen.width, anyway you have to concatenate the window property with the string in a proper way

window.open("http://www.google.com/","mywindow","width = " + window.screen.width + ", height = 300")


Related Topics



Leave a reply



Submit