Solved

How can I prevent 'target=_blank' from being added to my widget link?

deb_1
Visitor
2 0 1

I am trying to add a link to a page so that when an image is clicked, it will open the widget.

 

However, a target="_blank" is being added, which results in an "about:blank#blocked" page being opened. 

 

How can I stop this from happening? 

 

Example of the code: 

 

<a href="javascript&colon;void(0)" onclick="showWidget()"> <img src={image_link}/> </a>

 

But when I check the developer console, it is now: 

 

<a href="javascript&colon;void(0)" onclick="showWidget()" target="_blank"> <img src={image_link}/> </a>

 

Accepted Solution (1)

GemPages
Shopify Partner
5589 1261 1218

This is an accepted solution.

Hello @deb_1 ,

 

It's GemPages support team and glad to support you today.

 

According to my experience, in this case, the theme's script has a code to insert automatically target="_blank" to the <a> tag.

 

You could please try adding the below code to before </body> in the theme.liquid file:

  <script>
    $(document).ready(function(){
        $('a[href="javascript&colon;void(0)"]').each(function(){
          $(this).click(function(e){
            e.preventDefault()
          })
        });
    });
  </script>

 

If you require any further information, feel free to contact me.

 

Best regards,
GemPages Support Team

GemPages - Build any high-converting store pages for any business


- If you find my reply helpful, please hit Like and Mark as Solution
- Get connected: App Store | Blog | Community | Help Center

View solution in original post

Replies 3 (3)

GemPages
Shopify Partner
5589 1261 1218

This is an accepted solution.

Hello @deb_1 ,

 

It's GemPages support team and glad to support you today.

 

According to my experience, in this case, the theme's script has a code to insert automatically target="_blank" to the <a> tag.

 

You could please try adding the below code to before </body> in the theme.liquid file:

  <script>
    $(document).ready(function(){
        $('a[href="javascript&colon;void(0)"]').each(function(){
          $(this).click(function(e){
            e.preventDefault()
          })
        });
    });
  </script>

 

If you require any further information, feel free to contact me.

 

Best regards,
GemPages Support Team

GemPages - Build any high-converting store pages for any business


- If you find my reply helpful, please hit Like and Mark as Solution
- Get connected: App Store | Blog | Community | Help Center
deb_1
Visitor
2 0 1

Thank you!

GemPages
Shopify Partner
5589 1261 1218

I am glad that my solution is helpful to you.

 

Best regards,
GemPages Support Team

GemPages - Build any high-converting store pages for any business


- If you find my reply helpful, please hit Like and Mark as Solution
- Get connected: App Store | Blog | Community | Help Center