Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forms in Webkit HTML Notifications?

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>
like image 370
Gilean Avatar asked May 07 '10 01:05

Gilean


2 Answers

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.

like image 115
smfoote Avatar answered Sep 28 '22 15:09

smfoote


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

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

like image 27
Madara's Ghost Avatar answered Sep 28 '22 16:09

Madara's Ghost