# JS error on page but not on template causing functionality to not work

**URL:** <https://community.hubspot.com/t/js-error-on-page-but-not-on-template-causing-functionality-to-not-work/9672>\
**Category:** CMS Development\
**Created:** [July 31, 2018, 6:45pm UTC](https://community.hubspot.com/t/js-error-on-page-but-not-on-template-causing-functionality-to-not-work/9672 "2018-07-31T18:45:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DylanPress](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dylanpress/32/2679_2.png) [@DylanPress](https://community.hubspot.com/u/DylanPress)\
**Post date:** [July 31, 2018, 6:45pm UTC](https://community.hubspot.com/t/js-error-on-page-but-not-on-template-causing-functionality-to-not-work/9672/1 "2018-07-31T18:45:51Z")

</div>

I have these scripts that launch a video overlay when a button is clicked on my homepage

**Script in template head**

`<script src="https://fast.wistia.com/embed/medias/ci1kb2r0is.jsonp" async></script><script src="https://fast.wistia.com/assets/external/E-v1.js" async></script>`

**Button HTML on template**

`<p><span class="wistia_embed wistia_async_ci1kb2r0is popover=true popoverContent=link" style="display: inline; position: relative;"><a class="shadow-box btn btn-green" style="display: inline-block;" href="#">HOW AVANAN WORKS <img src="https://www.avanan.com/hubfs/play-button-1.png" alt="" title="play-button.png" width="25" style="width: 25px;"></a></span></p>`

This works fine on the template and when I preview the template.  
However when editing the page, Hubspot changes the HTML automatically to the following

**button HTML on page editor**

`<div id="wistia_47.thumb_container" class="wistia_click_to_play" style="position: relative; display: inline;"><a class="shadow-box btn btn-green" style="display: inline-block;" href="#">HOW AVANAN WORKS <img src="https://www.avanan.com/hubfs/play-button-1.png" alt="" title="play-button.png" width="25" style="width: 25px;"></a></div>`

and the functionality does not work. Instead I get the following error:

 ![javascript error .jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/8/d/8d672315807ae6d7e5d0d894764dfb043fea0e2a.jpeg)

How can I fix so the functionality on the page matches that of the template?

---

<div class="post-metadata">

**Author:** ![tjoyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tjoyce/32/88832_2.png) [@tjoyce](https://community.hubspot.com/u/tjoyce)\
**Post date:** [August 1, 2018, 12:18pm UTC](https://community.hubspot.com/t/js-error-on-page-but-not-on-template-causing-functionality-to-not-work/9672/2 "2018-08-01T12:18:58Z")

</div>

Hi @DylanPress - Can you try changing the span to a div and remove the wrapping \<p\> tag and see if that works?

```auto
<div class="wistia_embed wistia_async_ci1kb2r0is popover=true popoverContent=link" style="display: inline; position: relative;">
 <a class="shadow-box btn btn-green" style="display: inline-block;" href="#">HOW AVANAN WORKS <img src="https://www.avanan.com/hubfs/play-button-1.png" alt="" title="play-button.png" width="25" style="width: 25px;">
 </a>
</div>

```

* * *

If this answer helped, please, mark as solved 😄

* * *

[tim@belch.io](mailto:tim@belch.io) | [forms.belch.io](https://forms.belch.io) | Design your own Beautiful HubSpot Forms; No coding necessary.

Drop by and say Hi to me [on slack](http://slack.belch.io/).
