[英]onpaste event on asp.net textbox in internet explorer not working
[英]Is there a way to fire onPaste event on React Material <TableRow> in internet explorer?
我正在設計一個數據表,需要提供能夠粘貼從excel復制的數據行的功能。 但是,onPaste事件不會在Internet Explorer中觸發。 我能夠實現這一點,並在chrome中獲取剪貼板數據。
<Table className={classes.table} aria-labelledby="tableTitle">
<EnhancedTableHead
numSelected={selected.length}
order={order}
orderBy={orderBy}
onSelectAllClick={this.handleSelectAllClick}
onRequestSort={this.handleRequestSort}
rowCount={data.length}
/>
<TableBody onPaste={event => this.handlePaste(ClipboardEvent)}>
{stableSort(data, getSorting(order, orderBy))
.map(n => {
const isSelected = this.isSelected(n.id);
return (
<TableRow
hover
onClick={event => this.handleClick(event, n.id)}
role="checkbox"
aria-checked={isSelected}
tabIndex={-1}
key={n.id}
selected={isSelected}
>
<TableCell padding="checkbox">
<Checkbox checked={isSelected} />
</TableCell>
<TableCell component="th" scope="row" padding="none">
{n.udf}
</TableCell>
<TableCell align="right">{n.ticker}</TableCell>
<TableCell align="right">{n.transType}</TableCell>
<TableCell align="right">{n.qty}</TableCell>
<TableCell align="right">{n.portfolio}</TableCell>
</TableRow>
);
})}
{emptyRows > 0 && (
<TableRow style={{ height: 49 * emptyRows }}>
<TableCell colSpan={6} />
</TableRow>
)}
</TableBody>
</Table>
如果您查看文檔,則可以發現支持粘貼事件,並且OnPaste事件的兼容性未知。
我使用OnPaste事件進行了測試,發現該事件在Internet Explorer中正常運行。
問題是Internet Explorer不支持剪貼板數據。
因此,您將無法使用它訪問數據。
經過測試的代碼:
<!DOCTYPE html> <html> <body> <input type="text" onpaste="myFunction()" value="Try to paste something in here" size="40"> <p id="demo"></p> <script> function myFunction() { document.getElementById("demo").innerHTML = "You pasted text!"; } </script> </body> </html>
Internet Explorer 11中的輸出:
參考文獻:
(2) 元素:粘貼事件
作為替代方案,您可以嘗試參考以下鏈接中的示例,可以幫助您解決問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.