CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Open New Window

  1. #1
    Join Date
    Mar 2000
    Posts
    19

    Open New Window

    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.


  2. #2
    Join Date
    Mar 1999
    Location
    Nepal
    Posts
    540

    Re: Open New Window

    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.


  3. #3
    Join Date
    Mar 2001
    Location
    Toronto, CANADA
    Posts
    16

    Re: Open New Window

    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 |

  4. #4
    Join Date
    Mar 2000
    Posts
    19

    Re: Open New Window

    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!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured