// A Netscape3-specific way to generate an HTML page on-the-fly // and pass it to the browser. Simply generate a URL of the // form "javascript:'[Entire HTML Page]'" and call showDocument on it. // Note that there should NOT be any carriage returns in the string. // // 8/96 Marty Hall. hall@apl.jhu.edu, http://www.apl.jhu.edu/~hall/java/ import java.applet.Applet; import java.net.*; public class ShowHTML { //----------------------------------------------------------------- public static void showPage(Applet app, String html) { URL page = makeJavascriptURL(html); app.getAppletContext().showDocument(page); } //----------------------------------------------------------------- public static void showPage(Applet app, String html, String frameName) { URL page = makeJavascriptURL(html); app.getAppletContext().showDocument(page, frameName); } //----------------------------------------------------------------- // No \n's in the String! public static URL makeJavascriptURL(String html) { try { URL page = new URL("javascript:'" + html + "'"); return(page); } catch(MalformedURLException mue) { System.out.println("Illegal URL: " + mue); return(null); } } //----------------------------------------------------------------- }