How to determine if window.confirm() is supported?

后端 未结 5 2020
小鲜肉
小鲜肉 2021-01-23 06:09

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

5条回答
  •  粉色の甜心
    2021-01-23 06:27

    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.

提交回复
热议问题