Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a html file in browser from applet

Status
Not open for further replies.

clax99

Programmer
Oct 29, 2001
23
0
0
US
Im writing an applet that creates an "Internet quiz question" by taking user input and creating a html file that displays the question and such. I have a preview button, so i need to know how to open the newly created html file in a new window in the users browser. If this is not possible, is there some class i could use to display an html file to the user? Thanks in advance,
Clarence
 
You can use live connect to access some javascript on the
page to open a window and then write html to it.

import netscape.javascript.*;
public class myApplet extends Applet { public void init() {
JSObject win = JSObject.getWindow(this);
etc.............
etc...........
myString = new String(&quot;<HTML>\n yadda yadda this the html&quot;);
JSObject win = JSObject.getWindow(this);
String args2[] = {&quot;String&quot;};
win.call(&quot;test&quot;, args2);

The java script would look something like.........

var writeWin = null;
function writeOut(data) {
writeWin =
window.open('','aWin','top=0,left=0,width=250,height=350'); var ePen =data;
var wd = writeWin.document;
wd.open();
wd.write(ePen);
wd.close();//this finishs writting and opens the window.
}

This works in All version of netscape and ie that i've tried
it in.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top