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
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
java example issue 5 45
Netbeans and org.apache.commons.lang3 issue 3 26
Windows 7 to Windows 10 and back. IE 9.0, 10.0, 11.0 10 67
How to build a web site 17 56
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.
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

733 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