# Javascript Action to Button

**URL:** <https://community.hubspot.com/t/javascript-action-to-button/69966>\
**Category:** CMS Development\
**Created:** [November 24, 2022, 9:05pm UTC](https://community.hubspot.com/t/javascript-action-to-button/69966 "2022-11-24T21:05:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JRobertshaw](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jrobertshaw/32/38459_2.png) [@JRobertshaw](https://community.hubspot.com/u/JRobertshaw)\
**Post date:** [November 24, 2022, 9:05pm UTC](https://community.hubspot.com/t/javascript-action-to-button/69966/1 "2022-11-24T21:05:59Z")

</div>

Hi,  
I’m hoping someone can help, although familiar with HubSpot, I’m not overly familiar with Javaascript.

We are looking to use a “button” to trigger this javascript action to open up a new window (with locked address bar and page dimensions)  
window.open(‘[example.com](https://aus01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fexample.com%2F&data=05%7C01%7Cjrobertshaw%40agilitydigital.com.au%7C0dd09be14e574fd1db6008dacdf67309%7Cc0f7461975de453bbec02bc90808fc2c%7C0%7C0%7C638048756095385205%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=wGHFQVUneNJ4Ich1%2FGb3O586ip2MvtfQGmH5ldf5pG8%3D&reserved=0)’, ‘mysite’, ‘width=800,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no’);  
What would be the best to do this or add this action to a wrapper?  
Cheers

---

<div class="post-metadata">

**Author:** ![BarryGrennan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/barrygrennan/32/97794_2.png) [@BarryGrennan](https://community.hubspot.com/u/BarryGrennan)\
**Post date:** [November 25, 2022, 2:20am UTC](https://community.hubspot.com/t/javascript-action-to-button/69966/2 "2022-11-25T02:20:26Z")

</div>

Wrap it in a fuction and call the function on click.

`<button onclick="buttonFunction()">Click me</button>`

```lia-code-sample
<script>
function buttonFunction() {
window.open('https://example.com', 'mysite', 'width=800,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no'); 
}
</script>

```

Note that I include the https:// in the url, otherwise it will treat it as a subdirectory of the current page.

* * *

 ![profile2022a.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/2X/7/7273a34ccfe3489fceebc8a36eca751481b59531.jpeg)

**Barry Grennan**

[Freelance HubSpot CMS Developer](https://www.seoanseo.ca?utm_source=HubSpotCommunity)

[Website](https://www.seoanseo.ca?utm_source=HubSpotCommunity) | [Contact](https://www.seoanseo.ca/#contact?utm_source=HubSpotCommunity) | [LinkedIn](https://www.linkedin.com/in/barrygrennan)
