Dynamic Content
This section is for websites whose content loads or changes dynamically.
Changing Pages
When switching between pageviews dynamically, it is important to re-call
1ezstandalone.showAds()
ezstandalone.showAds()
calling this function following a change with to the URL will force ads to refresh on the new page.
New Content
For additional placeholders within the same pageview, you can use the ezstandalone.showAds
function.
If a user scrolls down the page, new content loads, and placeholders 104
and 105
are added, ezstandalone.showAds
should be used to display them.
1<script>
2 ezstandalone.cmd.push(function() {
3 // call new placeholders
4 ezstandalone.showAds(104, 105);
5 });
6</script>
Changing content
If the content changes within the same pageview and a placeholder is no longer needed or visible, the placeholder needs to be properly cleaned up using ezstandalone.destroyPlaceholders
. This allows the placeholder to be loaded again via ezstandalone.showAds
if necessary.
1<script>
2 window.ezstandalone.cmd.push(function() {
3 // destroy placeholders
4 ezstandalone.destroyPlaceholders(104, 105);
5 });
6</script>
Infinite Scroll
For sites which implement an infinite scroll, a combination of calling ezstandalone.destroyPlaceholders
followed by ezstandalone.showAds
may be necessary to reuse placeholders if within the same pageview.
in-content
placeholders specifically for infinite scroll.
Example
The example below shows the flow of an infinite scroll would look like on a site with multiple articles.
Start off by calling the placeholder for the first article on page load.
1<script>
2 window.ezstandalone = window.ezstandalone || {};
3 ezstandalone.cmd = ezstandalone.cmd || [];
4 ezstandalone.cmd.push(function() {
5 ezstandalone.showAds(102, 103, 104);
6 });
7</script>
User then scrolls to the next article, so the next set of ads are loaded.
1<script>
2 window.ezstandalone.cmd.push(function() {
3 // call new placeholders
4 ezstandalone.showAds(105, 106);
5 });
6</script>
User then scrolls to the third article, and the placeholders from the first article need to be reused.
1<script>
2 window.ezstandalone.cmd.push(function() {
3 // destroy initial placeholders
4 ezstandalone.destroyPlaceholders(102, 103, 104);
5 // call new placeholders
6 ezstandalone.showAds(102, 103, 104);
7 });
8</script>
Removing all placeholders
Remove all placeholders on the page by using the destroyAll
function
1<script>
2 window.ezstandalone.cmd.push(function() {
3 ezstandalone.destroyAll();
4 });
5</script>
Show all placeholders
You can call ads in every placeholder on a given page by using the showAds
function, without defining any value.
1<script>
2 window.ezstandalone.cmd.push(function() {
3 ezstandalone.showAds();
4 });
5</script>