PDA

View Full Version : Help about JScript Libraries


Dakota
11-24-2002, 05:22 AM
Ok! Let's see if someone will answer me.
I'm triyng to find out if there's a way to tell a button to load a library into my page.
I have a CLock that follows the mouse around and thought it could be funnier to try to create something like a on/off button for it... instead of having it follow the mouse for ever.
It's funny but it ain't that funny, that someone would want it for ever on!!! :)
The Problem about this is that i've made the clock a library so the html file could become smaller and...

Well, any ideas!
Thanks, ahead...

glenngv
11-25-2002, 01:46 AM
<input type="checkbox" onclick="if (this.checked) document.onmousemove=null;else document.onmousemove=FunctionToShowClock;">Hide clock

Dakota
11-25-2002, 03:12 AM
It did not work glenn.
But thanks anyway!!

glenngv
11-25-2002, 03:13 AM
can you post your code?

Dakota
11-25-2002, 03:18 AM
Here it goes attached!
Hope it helps!

glenngv
11-25-2002, 03:31 AM
is this in an external js? I cant get it to work, the onload is not called. can you post the html code too?

Dakota
11-25-2002, 03:41 AM
I still don't have html code for it!
I'm trying to build my first real page, and the clock was just an idea.
If you wan't you can put it in a page and try to work it!
That was what i have done. Tried it in a library (external .js) and in the page but still your code would not work! It had however more results than using a button why?
Well if you wan't you can try both ways, external or internal.
I'm just 'bout quiting!

glenngv
11-25-2002, 03:49 AM
if you don't have any html code, how did you try the code I posted and then tell me it's not working? Have you make it (without the code I posted) work in the first place?

maybe you got it from a site, could you post the link?

Dakota
11-25-2002, 03:57 AM
OK let us see if you can understand me.
I tried it like this:

<head>
...
<script language... src="ClockAtMouse.js">
</s...

and then

<body>
<form>
<input type="checkbox" onclick="if (this.checked) document.onmousemove=null;else document.onmousemove=Clock();">
</fo...

After that i tried to copy it into a html page, (a simple page, that i wrote just to test the code, since i want to make everything work to build a real page after, got it) and use your code it still wouldn't work!
Is it a conflict with the script or something?

glenngv
11-25-2002, 04:01 AM
seeing the actual js code, I know my posted solution wouldn't work. What you can do first is try to make it work without my code. As I asked before, do you get it from a site, can you post the link so that I can see it in action?

Dakota
11-25-2002, 04:24 AM
no i didn't get it from a site!
to see it in action use the attached file! Erase the .txt!

glenngv
11-25-2002, 05:24 AM
really? do you mean you created it yourself? :D
I've seen this effect before.

anyway, add this inside the body tag:

<input type="checkbox" onclick="if (this.checked) clearTimeout(timer); else timer=setTimeout('Delay()',20)">Don't follow my cursor!

and then change this line:

setTimeout('Delay()',20);

to:

timer=setTimeout('Delay()',20);


This will stop the clock from following the cursor but it may stopped while the clock pieces are not in the "proper" location.
If you want the clock to be in a specific position once the checkbox is checked, you will have to create a separate function that will position it to the desired place.