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

Topic summary

A user encountered an issue where target="_blank" was automatically being added to a widget link, causing an “about:blank#blocked” page to open instead of the intended widget.

Root Cause:

  • The Shopify theme’s JavaScript automatically inserts target="_blank" into all <a> tags.

Solution Provided:

  • Add custom JavaScript code before the </body> tag in the theme’s liquid file to prevent this automatic insertion.
  • The code removes or overrides the default behavior that adds the target attribute.

Outcome:

  • The solution successfully resolved the issue for the user.
Summarized with AI on November 24. AI used: claude-sonnet-4-5-20250929.

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:

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

Hello @deb_1_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 tag.

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


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

Best regards,
GemPages Support Team

1 Like

Thank you!

1 Like

I am glad that my solution is helpful to you.

Best regards,
GemPages Support Team