08-11-2009, 01:29 PM
|
#2 (permalink)
|
|
The Wanderer
Join Date: Aug 2009
Location: Pretoria, South Africa
Posts: 11
Thanks: 0
|
You are executing the code before the document has finished loading, thus it's not picking any of the dates up.
javascript Code:
<body> 2009-08-22 <script> var Matches = document.body.innerHTML.match(/\d{4}(\-)\d{2}(\-)\d{2}/); alert(Matches); //Null </script> </body>
Or you could just tell the javascript to execute once the document has finished loading.
javascript Code:
<head> <script> window.onload = function() { var Matches = document.body.innerHTML.match(/\d{4}(\-)\d{2}(\-)\d{2}/); alert(Matches); //Null } </script> </head> <body> 2009-08-22 </body>
Last edited by devnull : 08-11-2009 at 01:35 PM.
Reason: Highlighted :P
|
|
|