Jump to content

"Open in New Window" Not Working for Link

Recommended Posts

Hi all, I could use some advice on fixing a link on my website (the link for Broadway World). I'm trying to make it open in a new tab instead of diverting from my website.

When I go into the link editor, I can turn on the option to make it open in a new window, but that setting never saves. It always defaults back to opening in the same tab.

Has anyone else encountered this problem/figured out a solution?

Thanks!

Link to comment
  • 2 weeks later...
On 2/9/2023 at 9:01 AM, aeb556 said:

If option doesn't work, you can add this to Settings > Advanced > Code Injection > Footer

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
$(document).ready(function() { 
		$('.html-block [href*="broadway"]').attr('target','_blank');
	});
</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
  • 3 months later...
  • 7 months later...
16 hours ago, nataliaamelia said:

Hi, 
Is this code good for all links when added?

I want all my links to open in a new window. 

thanks!

 

 

 

All links, or all external links only? 

If all links, use this new code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
$(document).ready(function() { 
		$('a').attr('target','_blank');
	});
</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
11 hours ago, tuanphan said:

I emant external links

thanks! 

All links, or all external links only? 

If all links, use this new code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
$(document).ready(function() { 
		$('a').attr('target','_blank');
	});
</script>

 

 

Link to comment
15 hours ago, nataliaamelia said:

 

If external links, use this

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
$(document).ready(function() { 
$('a').attr('target', function() {
  if(this.host == location.host) return '_self'
  else return '_blank'
});
});
</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
  • 1 month later...
On 1/23/2024 at 9:11 AM, tuanphan said:

All links, or all external links only? 

If all links, use this new code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
$(document).ready(function() { 
		$('a').attr('target','_blank');
	});
</script>

 

What if files do not open in a new window? I tried this code, but it doesn't work for files. The same problem with the option 'Open in new tab', I click and it doesn't save.

Link to comment
18 hours ago, Arsel said:

What if files do not open in a new window? I tried this code, but it doesn't work for files. The same problem with the option 'Open in new tab', I click and it doesn't save.

Can you share link to page where you use files? I can check its id easier

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
  • 2 weeks later...

Maybe instead of a code injection...Squarespace could just make the toggle button work? Crazy, right? I simply want the materials visitors downloaded to open in a new tab. This isn't a big ask. There is already a toggle specifically for this...but it doesn't work. It would take a dev at Squarespace an hour to fix this...

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

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