Custom size (width/height)
In this tutorial we will show you how to better and simply change the Pingstreams Widget size on your website.
Steps to make them is very easy:
- Copy and paste the basic widget script code
- Subscribe to onInit Pingstreams event
- Add custom stylesheet to override the default values
Here is the full code example:
<html>
<head>
<script type="application/javascript">
var PROJECT_ID = "<<PINGSTREAMS_PROJECT_ID>>"
window.pingstreamsSettings=
{
projectid: PROJECT_ID,
startHidden: true,
};
(function(d, s, id) {
var w=window; var d=document; var i=function(){i.c(arguments);};
i.q=[]; i.c=function(args){i.q.push(args);}; w.Pingstreams=i;
var js, fjs=d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js=d.createElement(s);
js.id=id; js.async=true; js.src="https://widget.pingstreams.com/v6/launch.js";
fjs.parentNode.insertBefore(js, fjs);
}(document,'script','pingstreams-jssdk'));
window.Pingstreams('onInit', function (event_data) {
//var pingstreamsDiv = document.getElementById("pingstreamsdiv")
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
style.id = 'customStyle';
style.type = 'text/css';
style.innerHTML += '#pingstreamsdiv { height: 800px; width: 400px; }\n';
head.appendChild(style);
})
</script>
</head>
<body>
This Pingstreams example will change the widget size in height and width as you want
<div>
<b>Custom widget dimensions:</b> <span>800px height x 400px width</span>
</div>
</body>
</html>Key Points
Section titled “Key Points”- Use the
onInitevent to ensure the widget is fully loaded before applying custom styles - Target the
#pingstreamsdivelement to modify the widget container dimensions - You can customize both
heightandwidthproperties - The custom styles are applied dynamically after the widget initialization
View result here