Jump to content

Opening Page in New Window

Recommended Posts

Hi there,

I've written a script for a custom button to be added under my product page. However, I want the whatsapp url to be open in a new window upon clicking on the button.

Below is the script I've written:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
   <script>
   $(function() {
     $("<a class='whatsappbtn' href='https://api.whatsapp.com/send?phone=6588747658'> Whatsapp Us! </a>").insertAfter(".sqs-add-to-cart-button-wrapper");        
   });
</script>

 

Hope to get some help, thank you!

Link to comment
  • Replies 6
  • Views 523
  • Created
  • Last Reply

Hi. Use new code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
   <script>
   $(function() {
     $('<a class="whatsappbtn" href="https://api.whatsapp.com/send?phone=6588747658" target="_blank"> Whatsapp Us! </a>').insertAfter(".sqs-add-to-cart-button-wrapper");        
   });
</script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Thanks a bunch! I'm also looking to add a custom facebook icon on my product page. I'm currently having problem with adding the facebook image. Below is my code:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
   <script>
   $(function() {
     $("<a class='facebookbtn' href='https://facebook.com' img src='http://simpleicon.com/wp-content/uploads/facebook.png'>Facebook</a>").insertAfter(".sqs-add-to-cart-button-wrapper");        
   });
</script>

Mind helping with this as well? haha

Link to comment
4 hours ago, Lestor said:

Thanks a bunch! I'm also looking to add a custom facebook icon on my product page. I'm currently having problem with adding the facebook image. Below is my code:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
   <script>
   $(function() {
     $("<a class='facebookbtn' href='https://facebook.com' img src='http://simpleicon.com/wp-content/uploads/facebook.png'>Facebook</a>").insertAfter(".sqs-add-to-cart-button-wrapper");        
   });
</script>

Mind helping with this as well? haha

You mean add both fb + whatsapp on same position?

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
On 5/29/2021 at 10:40 AM, Lestor said:

Yup two buttons side by side. But for the fb, I want to use the facebook image icon instead of just a button

Try this code, if it doesn't work, can you share link to a product, we can check easier

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.2/css/all.css" integrity="sha384-vSIIfh2YWi9wW0r9iZe7RJPrKwp6bG+s9QZMoITbCckVJqGCCRhc+ccxNcdpHuYu" crossorigin="anonymous">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
   <script>
   $(function() {
     $('<a href="https://facebook.com"><i class="fab fa-facebook-square"></i></a><a href="https://api.whatsapp.com/send?phone=6588747658"><i class="fab fa-whatsapp"></i></a>').insertAfter(".sqs-add-to-cart-button-wrapper");        
   });
</script>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.