• Live group demo of Marketing Hub + Data Agent

    Standardize reporting, reduce manual work, and introduce AI without cleanup

    Join us on March 12
  • Marketing that's efficient and human? That's Loop Marketing.

    Explore HubSpot Academy's 39-video playlist and put it into practice.

    Start learning

Javascript Action to Button

JRobertshaw
Contributor

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 Accepted solution
BarryGrennan
Solution
Key Advisor

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

 

 

 

View solution in original post

0 Upvotes
1 Reply 1
BarryGrennan
Solution
Key Advisor

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