Forum Moderators: open
This is a fun one. Here is a thread that will help you understand the problem:
[webmasterworld.com...]
Can you use return false on the function call of the applet? I would assume you could in the end of the function you are calling.
try{
getAppletContext().showDocument( new URL(( "javascript:scrollPage()")));
}catch(java.net.MalformedURLException pl){
//do something here
}
In my html code I have
<script language = "JavaScript">
str = '<OBJECT classid = clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"';
function scrollPage(){
window.scrollTo(0,0);
}
</script>
How would I implement the above suggestion into this?
new URL(( "javascript:scrollPage()"))
the browser evaluates the 'new url' and 'refreshes' the page, so the page looses focus for a moment and the gifs stop.
You could give this a shot
import netscape.javascript.JSObject;
...
public void callJS(String jsFunction)
{
JSObject myHTMLDoc;
myHTMLDoc = JSObject.getWindow(this);
myHTMLDoc.eval("jsFunction";)
}
or just
import netscape.javascript.JSObject;
...
public void scrollIt()
{
JSObject myHTMLDoc;
myHTMLDoc = JSObject.getWindow(this);
myHTMLDoc.eval("scrollPage();");
}
<img name="ani_image1" src="ani_image1.gif"
then set an onfocus window event to 'reload' the images, (may already be in cached)
<SCRIPT language="JavaScript">
<!--
function reloadims()
{
document.ani_image1.src = "ani_image1.gif";
// more animated gifs here
}
window.onfocus = reloadims;
//-->
</SCRIPT>
<script language = "JavaScript">
str = '<OBJECT classid = clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"';
function scrollPage(){
window.scrollTo(0,0);
}
function reloadims()
{
document.3d_ball.src = "3d_ball.gif";
}
window.onfocus = reloadims();
</script>
But when I run it, I receive the following error and the gifs are all still frozen.
Line 1
Char 1
Error Object Expected
Any ideas?
Also probably not best to start the image name with a number something to do with W3 standards. (!)
What does the str assignment do? Doesn't look valid from here- two ' and one "?
try renaming your image to three_d_ball and doing
<script language = "JavaScript">
//str = '<OBJECT classid = clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"';
function scrollPage(){
window.scrollTo(0,0);
}
function reloadims()
{
document.three_d_ball.src = "3d_ball.gif";
}
window.onfocus = reloadims;
</script>
Sticky me the url when your done. I'm nosey.
It's either
There isn't a name attribute to the image tag?
-
<img name=three_d_ball src= ....
Or
The pointer to the named image is null because it hasn't been declared.
-
you need to insert the <script> after the image. Probably best to put it just before the </body>
I suspect that if the user clicks within the applet area the event will not bubble up to the window, so you may have to implement a Java mousedown within the applet to call the reloadims();
A possible fudge to avoid all this is just to
function reloadims()
{
document.three_d_ball.src = "3d_ball.gif";
}
setInterval("reloadims()",250);
which calls reloadims 4 times a second. Fudgetaskic!