Docs
A poll is made on loudpoll.com by staff, then shown on any page with one script tag. The widget lives in its own sealed box, so your page's styles can't change it.
On the edge of the window
<script src="https://loudpoll.com/embed/poll.js" data-poll="next-module" async></script>A handle on the right edge; the poll slides out from it. Beside LoudWidgets' widgets, the handles stack. One poll per page can sit on the edge.
Inside your page
<div id="poll"></div>
<script src="https://loudpoll.com/embed/poll.js" data-poll="next-module" data-target="#poll" async></script>At the element's full width, with no handle. A page can hold any number of these, one script tag each.
Options
- data-poll
- Which poll: its address on loudpoll.com (required). The admin shows it with the embed code.
- data-target
- An element to sit inside (any CSS selector). Without it the poll slides out of the window's edge behind a handle.
- data-voter-name
- The visitor's name, when your site already knows it. For polls that ask for a name, the field is filled and locked.
- data-accent
- A hex color that overrides the poll's own accent, for the Vote button and the bars.
- data-open
- On the edge only: "true" to start slid out.
- data-side
- "right" (the default), "left" or "bottom".
- data-position
- "bottom" (the default), "middle" or "top".
- data-offset
- On the edge only: pixels from the bottom or top of the window (24 unless set).
<script src="https://loudpoll.com/embed/poll.js" data-poll="next-module"
data-side="left" data-position="middle" data-voter-name="Sam Lee" async></script>JavaScript API
- LoudPoll.open()
- Slides the poll on the edge out.
- LoudPoll.close()
- Slides it back to its handle.
- LoudPoll.toggle()
- One or the other.
- LoudPoll.refresh()
- Reads every poll on the page again now.
- LoudPoll.identify(name)
- Tells every poll on the page who the visitor is, as data-voter-name does, once your site knows.
// once your site knows who's signed in
window.LoudPoll?.identify("Sam Lee");
window.LoudPoll?.open();Events
- loudpoll:ready
- A poll's script has started. detail: { poll } (its address).
- loudpoll:voted
- A vote went in. detail: { poll, choices: [{ option, votes }] }.
- loudpoll:closed
- The poll is closed (seen on load, or while it's showing). detail: { poll }.
window.addEventListener("loudpoll:voted", (e) => {
console.log(e.detail.poll, e.detail.choices);
});What a voter's browser keeps
A random voter number, the name they typed (when a poll asks), and a pass for each poll with a passcode, under keys starting loudpoll: in your site's storage. No cookies. Names and comments go only to the poll's staff on loudpoll.com; the widget shows counts.