473,659 Members | 2,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JS Clock Text Input

Art
Hi,

I'm using a form text input to display a JavaScript clock. It has no
other purpose than that, just show the date and time. What I would like
to do now is prevent anything else happening when it's moused over. I
was able to remove the cursor using the blur() method, something like
this:

document.formna me.inputname.bl ur();

The cursor appears for about a second then disappears. However, it still
activates. With WebTV I still get the yellow highlight around the input,
I presume the pointer changes to the finger when using a PC.

Is there a way to disable that with JavaScript, so that the input is
simply a static element on the page ? There are the WebTV only
attributes of "nohighligh t" and "noactivate ' which I don't want to use
as they are not part of any specification and probably have no effect
for PC users.

Thanks for any assistance.

Later, Art.

Jul 23 '05 #1
5 2843
Art wrote on 09 sep 2004 in comp.lang.javas cript:
I'm using a form text input to display a JavaScript clock.


Why?

An input is for inputting.

Cann't you simply use a span or a div to display something?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

Jul 23 '05 #2
Art
Hi,

I want the clock to be real time, second by second. I don't know that I
can accomplish that with what you suggest.

I did that with a document.write, however the clock did not increment
second by second. It remained at the time it was when the page was
entered/loaded.

Thanks for your reply.

Later, Art.

Jul 23 '05 #3
Art wrote:
I'm using a form text input to display a JavaScript clock. It has no
other purpose than that, just show the date and time.
To change the time every second, use setInterval and reset the value of
the control at each interval with the new date's value.

setInterval(
function(){
document.forms[0].elements["controlNam e"].value=
new Date();
},
1000
);
Is there a way to disable that with JavaScript, so that the input is
simply a static element on the page ?
Evertjan suggestion's might do the job, check the FAQ for DynWrite for a
way to change a text value other than in a form control:

<URL:http://jibbering.com/faq/>
attributes of "nohighligh t" and "noactivate ' which I don't want to use
as they are not part of any specification and probably have no effect
for PC users.
Well yes, but other hosts may perform other specific actions, you simply
have no way to prevent all of these (all the more there are 100+
browsers available).
Thanks for any assistance.


Even foolish one ? ;-)
<script type="text/javascript">
window.onload=f unction(evt){
var h=new Function(""),f= document.forms[0].elements;
for(var ii=0;ii<f.lengt h;ii++) { h=setWild(f[ii]); }
document.onclic k=function() { h(); }
setInterval(
function(){
for(var ii=0,dd=new Date();ii<f.len gth;ii++)
f[ii].value=dd;
},
1000
);
}

function setWild(el) {
var m={x:0,y:0}, q, a=[], page, pos, dim, r=true, tgl;

document.onmous emove=function( evt){
evt=evt||window .event;
m.x=evt.clientX ||evt.pageX||0;
m.y=evt.clientY ||evt.pageY||0;
}

page=function() {
var doc=document.co mpatMode &&
document.compat Mode.indexOf("C SS")!=-1 &&
document.docume ntElement||docu ment.body;
return {
width:window.in nerWidth||doc&& doc.clientWidth ||0,
height:window.i nnerHeight||doc &&doc.clientHei ght||0
};
}

pos=function(el ){
var p={x:0,y:0};
do {
p.x+=el.offsetL eft;
p.y+=el.offsetT op;
} while(el=el.off setParent);
return p;
}

dim=function(el ){
return {width:el.offse tWidth,height:e l.offsetHeight} ;
}

tgl=function(){
if((r=!r)) q();
}

q=function() {
for(var ii=0,pg=page(), ps,dm,M=Math;ii <a.length;ii++) {
ps=pos(a[ii]);
dm=dim(a[ii]);
if(!isNaN(ps.x) ) {
if(m.x>ps.x-100&&m.x<ps.x+d m.width+100 &&
m.y>ps.y-100&&m.y<ps.y+d m.height+100){
a[ii].style.position ="absolute";
a[ii].style.left=(M. abs(M.random()* pg.width-dm.width))+"px" ;
a[ii].style.top=(M.a bs(M.random()*p g.height-dm.height))+"px ";
}
} else {
r=false;
break;
}
}
if(r) setTimeout(argu ments.callee,42 );
}

return(q(),(set Wild=function(e l){return (a[a.length]=el,tgl);})(el) );
}
</script>

<form>
<input type="text" onfocus="this.b lur()" readonly="reado nly">
<input type="text" onfocus="this.b lur()" readonly="reado nly">
<input type="text" onfocus="this.b lur()" readonly="reado nly">
</form>

Jul 23 '05 #4
"Art" <Wa****@webtv.n et> skrev i meddelandet
news:17******** ********@storef ull-3333.bay.webtv. net...
Hi,

I want the clock to be real time, second by second. I don't know that I
can accomplish that with what you suggest.

I did that with a document.write, however the clock did not increment
second by second. It remained at the time it was when the page was
entered/loaded.

Thanks for your reply.

Later, Art.


Lookup the various DOM methods for manipulating text node content. That
would let you update text "live" (without form elements) on compliant
browsers.

Joakim Braun
Jul 23 '05 #5
JRS: In article <41************ ***********@new s.free.fr>, dated Thu, 9
Sep 2004 22:26:50, seen in news:comp.lang. javascript, Yann-Erwan Perio
<y-*******@em-lyon.com> posted :
Art wrote:
I'm using a form text input to display a JavaScript clock. It has no
other purpose than that, just show the date and time.

Read the newsgroup FAQ, and find my js-date2.htm.

It's rather pointless, except as a programming exercise. For date and
time elsewhere, see my js-date5.htm.

To change the time every second, use setInterval and reset the value of
the control at each interval with the new date's value.

setInterval(
function(){
document.forms[0].elements["controlNam e"].value=
new Date();
},
1000
);


That does not necessarily do every second. In Win98 it will miss about
one in 20; in NT perhaps 1 in 100 or 200; the fix is easy enough. As
above.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3588
by: Agency | last post by:
I'm still working on the bpm counter. I need to have at least 2 displays that are not static. One would be a clock/running time and the other would should the current beat count. How would I do this in Tkinter? I was thinkning of canvas-text, but there must be a widget for doing this kind of display. I'm a bit lost and would appreciate some help.
9
2249
by: Gino Elloso - Philippines | last post by:
Hello, I made a webpage ( @ Geocities Free Webpages ) that contains a mousetrail clock script. I simply copied the script ( including all html tags ) exactly as it was from a source webpage ( that contains only the functioning mousetrail clock ) and pasted it onto mine. But when I try to load the page I made, the clock won't show. Could someone help explain why the clock won't show on my page? Is there a special script for mousetrail...
1
1607
by: s.shahzaib.ali | last post by:
I want to make analog clock skin of windows media player so how can i roteate the layer upto 360 degrees with the help of javascript please tell me iam very anxious about it. iam the first and only skinner in Pakistan. i really need your help. Remember Analog clock Using XML LAYER Wit script of java. you just have tell me about java script i can work with xml well! HAVE A NICE DAY GOOD BYE!
33
47604
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
4
5004
by: 511475 | last post by:
Hi: I am an retired school teacher who went back to school for the fun of it. my subjects were computer hardware. I am taking a course in javascript and it is about to get the better of me. I need some help with is this one. I got it to validate. But something is wrong with the logic maybe. It bombs out on object expected . Please give me some input. thanks <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD...
12
4084
by: cenktarhancenk | last post by:
is there a way to display a ticking clock in a web page using javascript? but not in a textbox, rather as text that i can change the style, font etc. cenk tarhan
24
8536
TheServant
by: TheServant | last post by:
Hey guys, I used this free tutorial on how to make a live server clock. I did, but a) doesn't work (not too worried, I am sure I can fix this) and b) it out puts the clock to a input text field?! I want it to be in just a normal text display? The core code: <!-- function startclock() { var server_time = new Date();
8
1845
by: Theo v. Werkhoven | last post by:
hi, In this code I read out an instrument during a user determined period, and save the relative time of the sample (since the start of the test) and the readback value in a csv file. #v+ from datetime import * from time import * from visa import *
1
3524
by: ANB8503 | last post by:
Hello, I have created the below script; however, it's not showing in the box like it should... Help please!! I am running out of time to submit this assignment! Thanks in advance!! <script type="text/javascript"> /* <! ]> */ </script>
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2749
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.