View Single Post
Old 08-11-2009, 01:29 PM   #2 (permalink)
devnull
The Wanderer
 
Join Date: Aug 2009
Location: Pretoria, South Africa
Posts: 11
Thanks: 0
devnull is on a distinguished road
Default

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>
__________________
~ Work is love made visible ~

Flexible Programming Tips & Tricks

Last edited by devnull : 08-11-2009 at 01:35 PM. Reason: Highlighted :P
Send a message via Skype™ to devnull
devnull is offline  
Reply With Quote