Solved

is it possible to load a web page into a browser, and then shut the browser when loaded?

Posted on 2010-09-16
10
395 Views
Last Modified: 2013-12-29
I would like to use Java to open firefox and load a web page into it.  once the page finishes loading, i would like to end firefox.  how would i do this?  

opening firefox from java is easy, and executing a kill command to stop firefox is easy too.  but how would i find out when the page finishes loading?
0
Comment
Question by:trip008vk
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33694701
<<but how would i find out when the page finishes loading?>>
I dont think you can do this in java. Since after starting the browser, for your java program the task is completed, and control is no longer with your java program. After which firefox process cannot send any signal or interrupts to your java program.

You need to check if there is any command, which can tell given a browser's PID, what are the pages loaded and their status
0
 
LVL 3

Expert Comment

by:alanpetersen
ID: 33696880
Why are you trying to do this? If you simply want to hit a URL, you can easily do that within Java (I can give some sample code for that if you like). If you are firing up Firefox because you want that as your user-agent, it's easy to set that programmatically too. Then you don't have to mess with launching/killing Firefox.
 
0
 

Author Comment

by:trip008vk
ID: 33697484
i'm doing this because i need to run some javascript code in firefox, and then have the browser close...
0
 
LVL 3

Expert Comment

by:alanpetersen
ID: 33697615
Have you looked into the javax.script.ScriptEngine functionality? I don't know if this will necessarily solve your problem, but it might be worth considering.

http://download.oracle.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html
0
 
LVL 26

Accepted Solution

by:
ksivananth earned 500 total points
ID: 33698735
look at JDIC, you can achieve this using the status update event...
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:trip008vk
ID: 33718555
ksivananth, could you be a little more clear as to how to use JDIC to solve my issue?

thanks!
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 33722672
look at the downloadCompleted event fired when the page loading completed...
if you particular about the particular javascript function executed, you may want to change the status message from the javascript function which you can listen through JDIC. once you notified the status change event with that particular string you printed through javascript function, you can close JDIC!
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 500 total points
ID: 33722700
0
 
LVL 26

Expert Comment

by:ksivananth
ID: 33722703
0
 

Author Closing Comment

by:trip008vk
ID: 33763148
thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now