CMS Development

JRobertshaw
Contributor

Javascript Action to Button

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', '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 

0 Upvotes
1 Reply 1
BarryGrennan
Top Contributor

Javascript Action to Button

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

 

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

 

 

 

<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.

 

 


profile2022aBarry Grennan

Freelance HubSpot CMS Developer

Website | Contact | LinkedIn

 

 

 

0 Upvotes