8

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>
Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
Gilean
  • 14,708
  • 10
  • 45
  • 52
  • 1
    It's called a notification for a reason. It's meant to have the bare minimum or interactivity if any at all, and breaking that rule will likely annoy your users. – Max Shawabkeh May 07 '10 at 01:42
  • Star this bug to vote for it and receive email updates on it. http://crbug.com/56764 – Jason Hall Jun 21 '12 at 13:44

2 Answers2

3

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.

smfoote
  • 5,449
  • 5
  • 32
  • 38
2

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

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

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308