简体   繁体   English

HTML5 通知中的表单元素

[英]Form elements in a HTML5 Notification

I know that it is possible for an HTML5 Notification to display HTML, however if that HTML included form elements (buttons, selects, ect.), is it at all possible to interact with those inputs via javascript? I know that it is possible for an HTML5 Notification to display HTML, however if that HTML included form elements (buttons, selects, ect.), is it at all possible to interact with those inputs via javascript? An example would be to use the notification as a reminder UI, which would have a button to dismiss and one to snooze, and a select drop down to choose how long to snooze for.一个例子是将通知用作提醒 UI,它有一个按钮可以关闭,一个按钮可以打盹,还有一个 select 下拉菜单来选择打盹的时间。 Is there any way to attach listeners to these elements within the notification's content?有没有办法将侦听器附加到通知内容中的这些元素?

The function createHTMLNotification() requires an URL as argument, so you can put anything you like in the linked HTML page, including JS. function createHTMLNotification() 需要 URL 作为参数,因此您可以在链接的 HTML 页面中放入任何您喜欢的内容,包括 JS。

I have not tested this, but there doesn't seem to be any limit.我没有对此进行测试,但似乎没有任何限制。

Yes and No.是和否。

Yes, you can have buttons and links with event listeners bound to them to react to user's actions.是的,您可以将按钮和链接与事件侦听器绑定到它们上,以对用户的操作做出反应。

No, you can't have form elements like textareas, inputs, select, etc. The elements will show up in the notification but the user will not be able to interact with them.不,您不能拥有文本区域、输入、select 等表单元素。这些元素将显示在通知中,但用户将无法与它们交互。 I haven't been able to find any documentation on this.我还没有找到任何关于此的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM