if(!/^[a-zA-Z]+(\.[a-zA-z]+)?$/.test(filename) )
alert('Non English-Alpha characters in' +filename)
User Profile
Collapse
-
You are probably better off with the exponential notation.
Javascript loses precision after 15 or so digits.
928447654652812 3456781 may be rounded to
928447654652812 4000000, and
0.0000000000928 447654652812345 6781 to
0.0000000000928 4476546528124
If you need more precision you can use a javascript big integer library,
or hand off the calculations to a library on the server.
...Leave a comment:
-
Create a new Date object from the input and
use its getDay() or getUTCDay() method.
Saturday returns 6, Sunday is 0.
If d is a date object, d.getDay()%6==0 is true if the day is Saturday or Sunday.Leave a comment:
-
If you only care about the text content of a paragraph you can read it with:
Code:function textvalue(elementreference){ return elementreference.textContent || elementreference.innerText || ''; }Leave a comment:
-
Try something like this-
...Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html lang= "en"> <head> <meta http-equiv= "Content-Type" content= "text/html; charset=utf-8"> <style type= "text/css"> html, body{margin: 0; padding: 0} #scriptdiv{ position: absolute; top: 0; left: 0; width: 100%;Leave a comment:
-
If you declare your objects as globals with the var keyword, as in your example, you cannot delete them. The nearest you can get is to set them to undefined.Leave a comment:
-
define array
Code:var num = 1, array=[]; array[1] = 'Test'; alert(array[num]);
Leave a comment:
-
Is it possible that you do not have values defined for the options of the select element?
I mention this because in the absence of value attributes, browsers other than IE default to using the text content of the selected option as the value, and IE does not, in scripts. They all submit the text if there is no value, however.Leave a comment:
-
It depends on what you are doing with the elements.
Nodelists are live- if you start with the last element, and count down in the while loop, you can remove some of them safely. If you increment by one and remove an element, you'll skip the next one. Counting down is safer with nodelists.Leave a comment:
-
while (elem = elements[i]) may not mean what you thought.
Code:var elements= document.getElementsByName("name"), L= elements.length; while(L){ elem= elements[--L]; //do something }Leave a comment:
-
It looks like you are trying to get the offset size of an element whose style.display is 'none'.
offsets are figured from the rendered size of an element- the space it takes up in the browser window. If the display is none, it has no offset size, or 0.Leave a comment:
-
You could also use a string replace, with a function argument:
prefixing a digit with a plus sign coerces a number, adding the empty string returns the incremented integer as a string.Code:str= str.replace(/\d/g, function(n){ if(n== '9') return '0'; return ((+n)+1)+''; })Leave a comment:
-
onclick=
function(){
/*
if a timeout exists, clearTimeout(ti meout)
else
Set a timeout, say a quarter second, before calling the single click handler.
(In the single click handler, delete the timeout)
*/
}
I wouldn't put all this in the html- use an onload handler script to set it up.
You may prefer to use a button for the single click and double click the element, or use a button...Leave a comment:
-
You got me- if it works at all, it should clear the timeout and set a new one on a mouse move or key press. I could guess if it did nothing...
Let me know if you figure it out- I can't make it fail, but I don't know your set up.
Maybe try setting the handlers on the window or the document instead of the body, or put a doctype on the page if it has none- I'm just guessing, but maybe it gets the method from the initial call...Leave a comment:
-
//You don't need to know the coordinates to know if the mouse has moved.
...Code:function setdeadusertimer(){ clearTimeout(window.deadusertimer); window.deadusertimer= setTimeout(function(){ clearTimeout(window.deadusertimer); document.body.onmousemove= document.body.onkeypress= ''; alert('Wake up!'); /*call or define function here*/ }, 60000);Leave a comment:
-
You don't often have control of the user's status bar anymore.
When you do, changing the window.defaultS tatus only writes to the status bar when there are no window.status messages pending.
To keep the bar clear you have to catch any image, object or window loading events and return your message, or the empty string to window.status in place of the default return.
Don't bother, unless you are targetting quite...Leave a comment:
-
element={value: 'Lewis & Clark & John & James'};
element.value=e lement.value.re place(/ *& */g,' and ');
alert(element.v alue)Leave a comment:
-
You need a reference not to the iframe, but to the document in the window in the iframe:
var who=document.ge tElementById("i frMenu");
var document2= who.contentWind ow? who.contentWind ow.document || who.contentDocu ment;
document2.getEl ementById("mnuL evel")Leave a comment:
-
You are telling it to do so-
replace go() with go
The parens call the function immediatelyLeave a comment:
-
this version will prevent the input from showing the nondigits at all-
except in opera, which needs the onkeyup.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>key events</title>
<!--
This code is...Leave a comment:
No activity results to display
Show More
Leave a comment: