henry
Junior Member
Offline
Posts: 62
Re: using the <embed> tag over <object>
Reply #20 - Nov 23rd , 2008, 8:22pm
Thanks for getting back to me, I reviewed the situation my end and realise what you were trying to do with the JavaScript call - to have it execute. When in fact the JavaScript intervenes when a normal anchor link is requested, so executing it would do nothing. I then went back to the earlier examples and decided to try again to get the Java applet linking: Here's my code for the button: private static final int WIDTH = 100; private static final int HEIGHT = 100; private static final int HWIDTH = (WIDTH / 2); private static final int HHEIGHT = (HEIGHT / 2); private static final float LENGTH = (HEIGHT * .6); float theta = 0.0; float angle = 0.0; import netscape.javascript.*; void setup() { size(WIDTH, HEIGHT); smooth(); } void draw() { background(255); // move origin to centre translate(HWIDTH, 0); // theta will oscillate between -1 and 1 // we want the angle to go from about -45 from vertical to +45 from vertical // except we're using radians so -(PI/4) to +(PI/4) // ALSO 0 is to the right so add PI/2 to rotate it to the bottom // made this .2 * PI angle = HALF_PI + (sin(theta) * PI * .1); // With each cycle, increment theta theta += 0.03; drawCircle(LENGTH, LENGTH - 1); } void mousePressed() { // URL url = getDocumentBase(); // System.err.println(url); // try { link("http://projectmio.com/index.html#frontBottom","_self"); // URL anchor = new URL(url, "#frontBottom"); // System.err.println(anchor); // getAppletContext().showDocument(anchor); // } catch (MalformedURLException e) {} } // Learning Processing // Daniel Shiffman // http://www.learningprocessing.com // Example 13-8: Recursion (modified) void drawCircle(float len, float radius) { noFill(); float x = (len) * cos(angle); float y = (len) * sin(angle); ellipse(x, y, radius, radius); if(radius > 2) { // drawCircle() calls itself twice, creating a branching effect. drawCircle(len + radius / 7, radius / 2); drawCircle(len - radius / 1, radius / 2); } } I tried two ways, but they both open a new page within the same page, hense you can click back in the browser history and the #frontBottom anchor shows at the end of the URL, which means the JS did not catch it. void mousePressed() { URL url = getDocumentBase(); System.err.println(url); try { URL anchor = new URL(url, "#frontBottom"); System.err.println(anchor); getAppletContext().showDocument(anchor); } catch (MalformedURLException e) {} } AND link("http://projectmio.com/index.html#frontBottom","_self"); I am thinking now that maybe I need to create a piece of JS just for the flowing action to the #frontBottom anchor, so that the code you most recently posted will call it and the action will flow to the anchor. Unless there is a way of getting the JS to see the mouseclick when the Java applet is pressed like when the PNG image is pressed within the HTML. My domain is up now so here is the site: http://www.projectmio.com/ What do you think? Thank you!