Results 1 to 7 of 7

Thread: Webviewer and Javascript

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    Webviewer and Javascript

    Hi,

    How do I open a new window in my webbrowser1 object on my form?

    For example, navigating to <a href="http://www.google.com">GOOGLE</a> is fine.

    However, the link: <A HREF="javascript:newwindow()" >New popup</a> will open in IE. Can I force the link to open in me webbrowser, and a new instance of, instead of going to IE?

    Here is the JS code:

    <SCRIPT language="JavaScript">
    <!--hide

    function newwindow()
    {
    window.open('mypage.htm','jav','width=300,height=200,resizable=yes');
    }
    //-->
    </SCRIPT>

    Any help would be much appreciated.

    Blueevo.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Webviewer and Javascript

    try the before navigate event
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    Re: Webviewer and Javascript

    This does not catch the data unfortunately.

    I suppose I need to parse the JS function to get the URL, but not sure if this is feasable. I would be interested in hearing your thoughts?

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Webviewer and Javascript

    as many times when a new window is opened by java script, some variables are passed with the url, as parameters, it will probably take more than the url to make it work correctly

    if any events of the web browser can catch the navigation it should have the complete url with parameters, you can the cancel the navigation and open it in your browser

    other possibilities are to temporarily set your browser as default browser
    or not a good solution, but desperate measures.............
    loop through shell windows, find the new one, get the url and close, then open in your browser
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    Re: Webviewer and Javascript

    Thanks WestConn1, couple of good ideas there.

    On the point "Make my browser the default browser". How would I acheive this as it maybe a quick fix for me?

    I'll have a look in the forums to see if I can find out...

    Thanks again.

  6. #6

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    Re: Webviewer and Javascript

    Setting the default browser was pretty straight-forward. However, it did not solve my JavaScript popup window issue.

    On the following site, there are a couple of "Open Window 1" links.

    http://www.blazonry.com/javascript/windows.php

    If you open these in a VB Webbrowser, IE will popup with the new window, rather than your own webbrowser. There are no events that I can see to handle/prevent this and successfully gather the URL to open in my own browser.

    I would appreciate any guidance on this as I am at a loss at the moment.

    Many thanks!

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2011
    Posts
    7

    Re: Webviewer and Javascript

    Anyone have any suggestions on this please?

Tags for this Thread

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