# api.onPageChange werkt niet met eindeloos scrollen

**URL:** <https://meta.discourse.org/t/api-onpagechange-not-working-with-endless-scroll/179636>\
**Category:** Development\
**Created:** [14 februari 2021 om 07:16 UTC](https://meta.discourse.org/t/api-onpagechange-not-working-with-endless-scroll/179636 "2021-02-14T07:16:17Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![AstonJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/astonj/32/215041_2.png) [@AstonJ](https://meta.discourse.org/u/AstonJ)\
**Post date:** [14 februari 2021 om 07:16 UTC](https://meta.discourse.org/t/api-onpagechange-not-working-with-endless-scroll/179636/1 "2021-02-14T07:16:17Z")

</div>

I’m trying to change the tag links using the below and it seems to work on refreshing the page or going to a new page, but it does not work when you scroll down the page where endless scroll loads in new items:

```js
<script type="text/discourse-plugin" version="0.8">
	api.onPageChange(() =>{
		var tags = document.getElementsByClassName("discourse-tag");
		for (i = 0; i < tags.length; i++) {
			var tag = tags[i];
			var url = tag.href;
			var newUrl = "https://site.com" + url;
			tag.href = newUrl;
		}
	});
</script>

```

Do I need to use something other than or in addition to `api.onPageChange`?

---

_[View the full topic](https://meta.discourse.org/t/api-onpagechange-not-working-with-endless-scroll/179636)._
