I just found the problem which have been breaking my JavaScript all the time!
The function initial() fails the entire (well, most of it) if not all elements/IDs are available on the pages it loads with. Something which do not occur on all my pages.
Is it possible to rewrite this function so that it allows the script to work even if not all ellements are avaialble at all times?
[code]function initial() {
if (document.getElementById(‘s’).value == ”) {
document.getElementById(‘s’).value = ‘Search…’;
}
document.getElementById(‘s’).onfocus = searchFieldFocus;
document.getElementById(‘s’).onblur = searchFieldBlur;
if (document.getElementById(’email’).value == ”) {
document.getElementById(’email’).value = ‘[email protected]’;
}
document.getElementById(’email’).onfocus = emailFieldFocus;
document.getElementById(’email’).onblur = emailFieldBlur;
if (document.getElementById(‘author’).value == ”) {
document.getElementById(‘author’).value = ‘Given and Family name’;
}
document.getElementById(‘author’).onfocus = authorFieldFocus;
document.getElementById(‘author’).onblur = authorFieldBlur;
if (document.getElementById(‘url’).value == ”) {
document.getElementById(‘url’).value = ‘http://example.net/’;
}
document.getElementById(‘url’).onfocus = urlFieldFocus;
document.getElementById(‘url’).onblur = urlFieldBlur;
document.getElementById(‘searchForm’).onsubmit = searchFormRemoveExamples;
document.getElementById(‘newsletterForm’).onsubmit = newsletterFormRemoveExamples;
document.getElementById(‘commentForm’).onsubmit = commentFormRemoveExamples;
}
From [url=http://opensource-notebook.com/lib/script/formBehavior.js]http://opensource-notebook.com/lib/script/formBehavior.js.[url=http://opensource-notebook.com/subscribe/]this one
Round-up: If not all of these ellements: s, author, email, url, searchForm, newsletterForm and commentForm are pressent on the page, the script fails.