I have a mobile website that is used by various devices including some onboard computers running a locked down version of Windows Embedded 7 with IE 7. For some reason that I ca
You could do
if ('confirm' in window && typeof window.confirm === 'function' ) {
$(".logoff").click(function () {
return window.confirm("Are you sure you want to log off?");
});
}
if(typeof confirm=='function')// window.confirm is defined and a function
While the following suggested methods worked in every desktop browser I tested, they all evaluated to true on the device and still didn't display a dialog or navigate to the link in the anchor's href.
if (typeof confirm == 'object')
if ('confirm' in window && typeof window.confirm === 'object')
if (window.confirm)
(In IE 7, typeof somefunction
is 'object'
instead of 'function'
)
My solution was to use a jQuery UI Dialog instead, based on @ThiefMaster's suggestion.
How about:
if ('confirm' in window) {
$(".logoff").click(function () {
return window.confirm("Are you sure you want to log off?");
});
}
Another options would be window.hasOwnProperty('confirm')
.
You could use typeof to check if the window.confirm is a function