javascript file input onchange not working [ios safari only]

前端 未结 1 1369
难免孤独
难免孤独 2021-02-14 11:44

The code below works everywhere except on safri mobile. Apparently the onchange is never triggered.

 // create a hidden file input element
 var input  = document         


        
1条回答
  •  情书的邮戳
    2021-02-14 11:56

    I'll be damned: on iOS safari two extra conditions are necessary compared to other browsers:

    1) The input must be actually appended to the DOM.

    2) setting .onchange won't work: addEventListener must be used instead.

    0 讨论(0)
提交回复
热议问题