The poll unit JavaScript function is called to load the instance into the container. The function accepts one argument: an object providing the poll unit settings.
Here is a basic example:
civicscience.widget({
target: "000",
container: "#civsci-id-123456789"
});
Here is a more complex example with articleUrl
, recommended for the poll unit integration code placed inside an <iframe>
:
civicscience.widget({
target: "000",
container: "#civsci-id-123456789",
articleUrl: "https://url-to-article",
forceDarkMode: false
});
The articleUrl
is optional. articleUrl
should only be used when the poll unit integration code is being loaded from inside an <iframe>
. If the poll unit is loaded inside a wrapping <iframe>
, articleUrl
should identify the exact URL of the web page that is parent to the containing <iframe>
. If the poll unit is placed inside an <iframe>
without a unique articleUrl
set, certain features like sharing, pinning questions, and poll unit positioning through the admin tool will not work.
The forceDarkMode
is optional. forceDarkMode
should only be used when the web page containing the poll unit forces a dark mode on the user, regardless of the user's Operating System Dark Mode settings. It is recommended that Dark Mode be enabled for the poll unit in the InsightStore Target > Settings > Theme page instead of using the forceDarkMode
poll unit function parameter.
Both the target
and container
settings are required.