Reputation: 82
I created a small applet for my sister's blog that flashes colors randomly. She wants to set it as her background for her webpage. I've already figured out how to find the size of a web page and all that, but how do I declare the applet's width and height to be values of my functions?
Here's the tester page code:
<html>
<head>
<title>Flashing colors</title>
<script type="text/javascript">
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
x = w.innerWidth || e.clientWidth || g.clientWidth,
y = w.innerHeight|| e.clientHeight|| g.clientHeight;
function getWidth(){
return x;
}
function getHeight(){
return y;
}
</script>
</head>
<body>
//Here's the problem
<applet code="FlashingColors.class" width=getWidth() height=getHeight()>
</applet>
</body>
</html>
I have no experience in html or javascript, but plenty in Java. If someone could explain what to do and why it works, that would be nice.
Update: At this point, I do realize that one wouldn't use an applet, but at this point I just want to figure out how to make it work, because I am curious and want to learn.
Upvotes: 0
Views: 197
Reputation:
You can't reliably layer HTML content on top of Java applets in a web page. So this won't work anyway.
Learn a little bit more Javascript and use that to implement the same effect. It will work much better. (To get you started: You can assign an HTML color value directly to the document.body.style.backgroundColor
property.)
Upvotes: 2