473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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.formname.inputname.blur();

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 "nohighlight" 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 2827
Art wrote on 09 sep 2004 in comp.lang.javascript:
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["controlName"].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 "nohighlight" 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=function(evt){
var h=new Function(""),f=document.forms[0].elements;
for(var ii=0;ii<f.length;ii++) { h=setWild(f[ii]); }
document.onclick=function() { h(); }
setInterval(
function(){
for(var ii=0,dd=new Date();ii<f.length;ii++)
f[ii].value=dd;
},
1000
);
}

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

document.onmousemove=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.compatMode &&
document.compatMode.indexOf("CSS")!=-1 &&
document.documentElement||document.body;
return {
width:window.innerWidth||doc&&doc.clientWidth||0,
height:window.innerHeight||doc&&doc.clientHeight|| 0
};
}

pos=function(el){
var p={x:0,y:0};
do {
p.x+=el.offsetLeft;
p.y+=el.offsetTop;
} while(el=el.offsetParent);
return p;
}

dim=function(el){
return {width:el.offsetWidth,height:el.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+dm.width+100 &&
m.y>ps.y-100&&m.y<ps.y+dm.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.abs(M.random()*pg.height-dm.height))+"px";
}
} else {
r=false;
break;
}
}
if(r) setTimeout(arguments.callee,42);
}

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

<form>
<input type="text" onfocus="this.blur()" readonly="readonly">
<input type="text" onfocus="this.blur()" readonly="readonly">
<input type="text" onfocus="this.blur()" readonly="readonly">
</form>

Jul 23 '05 #4
"Art" <Wa****@webtv.net> skrev i meddelandet
news:17****************@storefull-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***********************@news.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["controlName"].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.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.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
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...
9
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 (...
1
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...
33
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
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...
12
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
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?! ...
8
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+...
1
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!! ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.