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
394 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Internet is a big network which is formed by connecting multiple small networks.It is a platform for all the users which are connected to it.Internet act as platform in different fields. Such as: Internet  as a collaboration platform. Internet  as…
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

708 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

20 Experts available now in Live!

Get 1:1 Help Now