This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to set an applet ID in your html

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my java script I want to use the following:
var applet = document.getElementById("AppletID");
What do I use in my html <object> tag (where I define the applet embed) to generate an ID that my javascript can use?
Thanks, Jay.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello there, see you made the trip from the coding forums.
I am not exactly sure what you want, but I will try
you can use the param tag inside of an applet tag
<applet code="Hello.class" width.....blah... id="TheApplet">
<parm name="display" value="This is some text">
</applet>
You can do the same thing with the object tag
then you should be able to access it with javascript
Javascript is also able to use the public properties and methods and that is what I showed you at the CF. So if you were to set the variable in the public properties you can use the method I showed you.
Eric
I am not 100% sure if I answered your question, if not, I will make sure I get the Java Gurus here to help you out!
 
Jay Schrock
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Eric, yes I made the switch, lots of really good information in these forums.... Thanks for your help. I was able to add a NAME parm in the object tag, then refer to that in my java script as the ID... Below is an example html tag followed by the java script function that calls a method in the script. Everything works great!! Talk to you later, Jay.
<OBJECT
NAME = "UBB"
classid = "clsid:CAFEEFAC-0014-0001-0000-ABCDEFFEDCBA"
codebase = "http://java.sun.com/products/plugin/autodl/jinstall-1_4_1-windows-i586.cab#Version=1,4,1,0";
WIDTH = 300 HEIGHT = 75 >
<PARAM NAME = CODE VALUE = "HelloWorld.class" >
<PARAM NAME = "type" VALUE = "application/x-java-applet;jpi-version=1.4.1">
<PARAM NAME = "scriptable" VALUE = "false">
<COMMENT>
<EMBED
type = "application/x-java-applet;jpi-version=1.4.1"
CODE = "HelloWorld.class"
WIDTH = 400 HEIGHT = 400
scriptable = false
pluginspage = "http://java.sun.com/products/plugin/index.html#download">;
<NOEMBED>
alt="Your browser understands the <APPLET> tag but isn't running the applet, for some reason."
Your browser is completely ignoring the <APPLET> tag!
</NOEMBED>
</EMBED>
</COMMENT>
</OBJECT>

function changeit(strin) {
var applet = document.getElementById("UBB");
applet.change(strin);
applet.repaint();
}
 
    Bookmark Topic Watch Topic
  • New Topic