I am trying to open a new IE window using VBScript but I want the window that is opened to be centered on the screen. How can I do this? Thanks.
Printable View
I am trying to open a new IE window using VBScript but I want the window that is opened to be centered on the screen. How can I do this? Thanks.
I don't have the exact code to do it, but I'll tell you one way to do it.
Run IE using the Shell Command
It's caption will invariably have Microsoft Internet Explorer in it.
Iouri has recently posted a code in this forum that will return the handle to the window when you know part of it. Use it to obtain the handle to it.
Then use the MoveWindow() API function to center the window with that handle on the screen.
Here's some code I used on my website recently...
<script language="javascript">
var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
}
</script>
....and here is how you would call the script in your link:
<a href="http://nawedshaikh.com" onclick="NewWindow(this.href,'name','400','400','yes');return false">Website Abstraction</a>
[n]Shaikh
| http://nawedshaikh.com |
What does the question mark do when you are setting the LeftPosition and TopPosition values? I am trying to use VBScript to do the same thing because the code for my link is in asp as well, so the JavaScript doesn't want to work with it. Thanks for the help!