Thursday, June 23, 2011

opening a window in dual monitor next monitor using javascript...


I was running through a requirement in which client needs to make sure the payment bill window is opened in next monitor if user is using dual monitor.
Sounds tricky in web world right? Without any controls / active X?
After running through some research (google research) I understood that its just you move your  IE window out of your screen resolution and it will start appearing in next monitor hehe!
Use following javascript to help…
<script>
function popup_params(width, height) {
    var a = typeof window.screenX != 'undefined' ? window.screenX : window.screenLeft;
    var i = typeof window.screenY != 'undefined' ? window.screenY : window.screenTop;
    var g = typeof window.outerWidth!='undefined' ? window.outerWidth : document.documentElement.clientWidth;
    var f = typeof window.outerHeight != 'undefined' ? window.outerHeight: (document.documentElement.clientHeight - 22);
    var h = (a < 0) ? window.screen.width + a : a;
    var left = parseInt(h + ((g - width) / 2), 10)+1500;
    var top = parseInt(i + ((f-height) / 2.5), 10)+1500;
    return 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=1';
}  
window.open("http://google.com", "windowname", "location=1,toolbar=0," + popup_params(300, 300));
</script>
#trivedimehulk@gmail.com

1 comment:

  1. this is called out of the box programming....hahahaha

    ReplyDelete