0

Hi I am trying to open HTML file in Firefox browser with following code

 Dim NewProcess As Process
 NewProcess.Start(url1)

by default it is opening in Firefox as my default browser is Firefox but it is opening with all tools and menu bar how can I open it without tools and menu.

how Can I use

window.open(url,"MyWindow","config='toolbar=no, menubar=no,scrollbars=no,resizable=no,location=no,directories=no,atus=no'");

propery to this page

1
  • See my edit. I made an edit to my second code where your app waits until the process has opened, then waits 1,5 seconds to then close the window that you do not want. Commented Feb 4, 2016 at 10:32

1 Answer 1

1

You can try passing the -url parameter along with that code of yours when opening a new Firefox process.

Dim NewProcess As Process = Process.Start("firefox.exe", "-url ""javascript:window.open('" & url1 & "','MyWindow','config=toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,atus=no');""")

EDIT:

Alternatively (since this does not seem to work in all cases) you could write a temporary HTML file which when opened creates a new window per your specifications.

Public Const BaseWindHTML As String = "<script>window.open('<replaceurl>','MyWindow','config=toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,directories=no,atus=no'); window.close();</script>"

Public Sub OpenNewWindow(ByVal URL As String)
    Dim HTMLPath As String = IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory(), "newwindow.html")

    Using Writer As New IO.StreamWriter(HTMLPath, False)
        Writer.Write(BaseWindHTML.Replace("<replaceurl>", URL))
    End Using
    Dim fProcess As Process = Process.Start("firefox.exe", "-url """ & HTMLPath & """")
    fProcess.WaitForInputIdle()
    Threading.Thread.Sleep(1500)
    fProcess.CloseMainWindow()
End Sub

Example use:

OpenNewWindow("http://www.google.com/")
Sign up to request clarification or add additional context in comments.

6 Comments

I tried this solution but the "newwindow.html" is also opening with the url so two windows are opening at a time I want only a url window to be open while with start process.
window.close() is not closing this window
@AnujaDeshpande I know you only want one window. I will try another workaround since window.close() does not seem to work.
I tried with the fProcess.Kill() it is killing both the browser windows.
@AnujaDeshpande : Hmmh, try replacing fProcess.Kill() with fProcess.CloseMainWindow(). I've updated the answer to that too (I'm afraid I won't be able to test this yet though).
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.