# baseURI not valid in decorateCooked

**URL:** https://meta.discourse.org/t/baseuri-not-valid-in-decoratecooked/250624
**Category:** Development
**Tags:** plugin-api
**Created:** [January 3, 2023, 10:05pm UTC](https://meta.discourse.org/t/baseuri-not-valid-in-decoratecooked/250624 "2023-01-03T22:05:10Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![markschmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markschmucker/32/141599_2.png) [@markschmucker](https://meta.discourse.org/u/markschmucker)
#### Post date: [January 3, 2023, 10:27pm UTC](https://meta.discourse.org/t/baseuri-not-valid-in-decoratecooked/250624/3 "2023-01-03T22:27:55Z")

</div>

I’m trying to do this:

> [@How to get topic slug or id from PluginAPI?](https://meta.discourse.org/t/how-to-get-topic-slug-or-id-from-pluginapi/250362):
>
> PluginAPI newbie here. I have a working script something like: api.decorateCooked($elem =\> { var iframes = $elem[0].querySelectorAll('iframe'); var uri = $elem[0].baseURI; // modify the iframes in a way that depends on the topic }); I’m using the uri as a key into another database to know how to modify the iframes. However I think this will break if the topic is moved; in any case I would prefer to use the topic id or slug. Is there a way to get those from the PluginAPI?

I think I can use window.location.href instead, but thought I’d point out the inconsistent behavior.

I’m very new at this and don’t understand when I should use decorateCooked and when should I use onPageChange as you suggest, and what other events there might be.

---

_[View the full topic](https://meta.discourse.org/t/baseuri-not-valid-in-decoratecooked/250624)._
