# Grabbing URL Parameters in Custom HTML widget

**URL:** <https://forums.losant.com/t/grabbing-url-parameters-in-custom-html-widget/5561>\
**Category:** Help\
**Tags:** dashboard\
**Created:** [August 10, 2024, 7:36pm UTC](https://forums.losant.com/t/grabbing-url-parameters-in-custom-html-widget/5561 "2024-08-10T19:36:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blake\_Harriman](https://avatars.discourse-cdn.com/v4/letter/b/8e8cbc/32.png) [@Blake\_Harriman](https://forums.losant.com/u/Blake_Harriman)\
**Post date:** [August 10, 2024, 7:36pm UTC](https://forums.losant.com/t/grabbing-url-parameters-in-custom-html-widget/5561/1 "2024-08-10T19:36:42Z")

</div>

I have a button that redirects a user from one dashboard to another. I need to pass some data between the first and second dashboard so I am adding it as a parameter to the URL. In the second dashboard it seems that I am unable to grab it. The parameter shows up in the URL like expected, but using window.location.search in the Custom HTML widget just returns an empty string so I can’t actually grab that parameter. I thought maybe creating a context variable with the same name/key in the second dashboard would work, but it doesn’t look like that is getting set either when the page loads. Is there any solution to this?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [August 11, 2024, 8:11pm UTC](https://forums.losant.com/t/grabbing-url-parameters-in-custom-html-widget/5561/2 "2024-08-11T20:11:36Z")

</div>

A Custom HTML Block renders within the context of its own [`<iframe />`](https://www.w3schools.com/html/html_iframe.asp), so the `window` scope is not available within it. You can read more about that security feature [here](https://stackoverflow.com/questions/3420004/access-parent-url-from-iframe).

Instead, I would create a [context variable](https://docs.losant.com/dashboards/context-variables/) for the value you want to pass through, and you can [set that variable’s value through a query parameter](https://docs.losant.com/experiences/views/#context-variables) (assuming you are doing this in an experience page).

---

<div class="post-metadata">

**Author:** ![Blake\_Harriman](https://avatars.discourse-cdn.com/v4/letter/b/8e8cbc/32.png) [@Blake\_Harriman](https://forums.losant.com/u/Blake_Harriman)\
**Post date:** [August 12, 2024, 5:05pm UTC](https://forums.losant.com/t/grabbing-url-parameters-in-custom-html-widget/5561/3 "2024-08-12T17:05:57Z")

</div>

I followed these steps, but it seems that I’m still running into issues. I added a context variable called storeNum to the experience page and set it equal to {{request.params.storeNum}}. I have a context variable in the dashboard as well with the same name and a default value of 5. I’m logging the ctx variables after the page loads, but it seems that the value is always stuck at 5 on the experience page. I’ve tried loading the page with both “?storeNum=10” and “?ctx[storeNum]=10”, but no dice. When I try it on the dashboard it works just fine however so I’m not exactly sure what’s different or what I’m doing wrong.

 ![Screenshot 2024-08-12 at 12.58.31 PM](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/ed56265c7918ccea2951fe9b0194462f0810c23b.png)

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [August 12, 2024, 5:16pm UTC](https://forums.losant.com/t/grabbing-url-parameters-in-custom-html-widget/5561/4 "2024-08-12T17:16:49Z")

</div>

That should be `{{request.query.storeNum}}` if you’re passing it as a query parameter.

At the top of the page editor you will see a “View Example Context” link. You may find that helpful when building this out.
