Safari 5.1 prompt() function and cancel

后端 未结 5 940
抹茶落季
抹茶落季 2020-12-18 20:00

In most browsers (including older versions of Safari), the Javascript prompt function returns null when the user clicks \"Cancel\", and the empty s

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-18 20:47

    var res = prompt('hello?', '')
    if (res === null || res === '' && isSafari && confirm('was that cancel?'))
        cancel
    

提交回复
热议问题