M
Moses
Hi All,
Is is possible to catch the error of an undefined element while
creating an object for it.
Consider we are not having an element with id indicator but we
are trying to make the object for it
indicator = document.getElementById('indicator');
Though we dont have any element like 'indicator' we wont get any
error
but if we try like this
indicator.style.innerHTML = 'Loading'
which throws the error "Indicator has no Properties"
Is it possible to catch the error while creating an object
itself
(ie)
try
{
indicator = document.getElementById('indicator');
}
catch(e)
{
//No Error
}
but
try
{
indicator.style.innerHTML = 'Loading'
}
catch(e)
{
// Here we get the error
}
But I need to cache the error while Creating the object itself , ie
If I try to create an object for an undefined element the error
should be thrown.
Is it posible.
Thanks & Regards
Moses
Is is possible to catch the error of an undefined element while
creating an object for it.
Consider we are not having an element with id indicator but we
are trying to make the object for it
indicator = document.getElementById('indicator');
Though we dont have any element like 'indicator' we wont get any
error
but if we try like this
indicator.style.innerHTML = 'Loading'
which throws the error "Indicator has no Properties"
Is it possible to catch the error while creating an object
itself
(ie)
try
{
indicator = document.getElementById('indicator');
}
catch(e)
{
//No Error
}
but
try
{
indicator.style.innerHTML = 'Loading'
}
catch(e)
{
// Here we get the error
}
But I need to cache the error while Creating the object itself , ie
If I try to create an object for an undefined element the error
should be thrown.
Is it posible.
Thanks & Regards
Moses