Webkit HTML 通知中的表单?

发布于 2024-08-31 14:25:22 字数 409 浏览 3 评论 0原文

是否可以在 Webkit HTML 桌面通知中使用表单元素?我尝试从 Chrome 扩展程序打开 HTML 通知,并且出现我添加的 ,但我无法输入内容。我希望能够捕获其中的输入并保存它。

var notification = webkitNotifications.createHTMLNotification(chrome.extension.getURL('input-prompt.html'));
notification.show();

<html>
<body>
<form><input type="text" name="here" value="test" /></form>
</body>
</html>

Is it possible to use form elements in Webkit HTML desktop notifications? I'm tried to open a HTML notification from a Chrome extension, and the <input> I added appears, but I cannot type in it. I'd like to be able to capture the input from it and save it.

var notification = webkitNotifications.createHTMLNotification(chrome.extension.getURL('input-prompt.html'));
notification.show();

<html>
<body>
<form><input type="text" name="here" value="test" /></form>
</body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神经大条 2024-09-07 14:25:22

您可以通过一种非常简单的方式解决这个问题。您可以创建一个用作输入框的 div,并允许编辑该 div 的内容 (看这里)。然后你可以使用一个按钮或另一个div作为提交按钮,然后用javascript处理表单提交。

<div contenteditable="true" id="inputBox"></div>
<div id="submitButton" onclick="submitform();">Submit</div>

虽然我同意桌面通知可能不应该包含表单,但我有一个情况,在通知中包含表单实际上更方便。我希望这有帮助。

You can get around this in a pretty simple way. You can create a div that serves as your input box, and allow the content of the div to be edited (look here). Then you can use a button or another div as the submit button, then handle the form submit with javascript.

<div contenteditable="true" id="inputBox"></div>
<div id="submitButton" onclick="submitform();">Submit</div>

While I agree that desktop notifications are probably not meant to contain forms, I have a case where having a form in the notification is actually more convenient. I hope this helps.

江湖正好 2024-09-07 14:25:22

通知并不用于交互。他们的目的是通知。

如果您想实现互动,请使用操作反而。

Notifications are not meant for interactivity. They are meant to notify.

If you want to have interactivity, use an Action instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文