Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0
Cirqster

Gallery: External link in new window/tab?

Question

I have an image in my gallery that i need to link to an external site. I need this to open in a new tab otherwise it will send customers off of my site, not ideal.

Squarespace have told me this is not a currently available feature (no idea why).

Does anyone know a way around this/way to inject code to help me out?

Edited by Cirqster
Tidy

Share this post


Link to post

Recommended Posts

  • 0

I'm having a related issue using a link to a PDF in the Gallery page.

I have added the code above, as suggested, to the end of the pdf title. But the added code doesn't seem to make a difference -- the PDF just opens in the same tab of the web browser, just as before.

The PDF file with added code is:

BreathebyDavidLobenstineSpreads.pdf"target="blank

What am I doing wrong?

(And if you want to see the webpage itself: https://fullbreathmassage.com/writings)

Thanks much for your help!

David

Share this post


Link to post
  • 0

Thank you for explaining this! Now I get a slight idea of what I'm doing :) It works like charm for most links.

BUT NOT for the ones that end with / (slash). The code that I add after / seems to be treated as part of the address and not as code. It still takes me to the target website but I end up with the Page Not Found message.

https://sitename.com/some-blog/article-about-something"target="_blank - OK

https://sitename.com/some-blog/article-about-something/"target="_blank - NOT OK :(

I tried deleting / and then adding "target="_blank => Page Not Found

Please help!

Edited by serrta
Initial Revision

www.afterworkdiy.ru

Share this post


Link to post
  • 0

I'm using Forte template and the "target="_blank does not work for me when inserted after the link into the clickthrough drop down.

Any idea why??

https:mylink.com"target="_blank

doesn't work...

Share this post


Link to post
  • 0

I am using Five template, have a Gallery Summary Block placed on homepage that was not allowing links (video, pdfs) to open in a new browser window.

After much searching, reading, trial and error, I think I finally pieced together a method to make all of the links in a gallery summary block open in a new browser window (without affecting the rest of the links on the site page).

First, enable jQuery on your site by going to main menu (Settings/Advanced/Code Injection) and pasting this code snippet into the header field:


<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>

Next, go to the page you want your gallery summary block to allow external links to happen on, and go to (Settings/Advanced/Page Header Code Injection) and paste this code snippet in the box:


<script>
$(document).ready(function() {
   $('.sqs-gallery-container a').click(function(event) {
       event.preventDefault(); // preventDefault first
       var link = $(this).attr('href');

       if(link != '#'){
           window.open(link);
       }
   });
});
</script>

I tested this on my page, every link on the site works normally, and all of the gallery summary block links now open in a new browser window.

NOTE: if you are using multiple gallery summary blocks on one page, this code snippet will affect ALL of them... so if you only want to have it affect one particular gallery summary block, you will need to specifically call out that gallery summary block in the page snippet.

This is the section of code you would need to change in the snippet:


$('.sqs-gallery-container a').click(function(event) {

In my case, the gallery summary block I needed to change was the 2nd of 3 on my index page. I viewed the page in Preview mode, then right-clicked and selected"View Source"... then scrolled (and scrolled... and scooooolllled) until I found which gallery summary block it was (summary-thumbnail-container) and edited the code snippet to reference that block specifically:


<script>
   $(document).ready(function() {
       $('.summary-thumbnail-container').click(function(event) {
           event.preventDefault(); // preventDefault first
           var link = $(this).attr('href');

           if(link != '#'){
               window.open(link);
           }
       });
   });
   </script>

I saved and previewing my page, and bah-da-bing, just the intended gallery summary block opened links in external browser windows, leaving the other gallery blocks alone and not affecting any other links on my page.

Advanced coders (who didn't start out web coding in good ol' html waaaaay back when dinos ruled the planet) - feel free to chime in on suggestions/improvements to this method, as I am not familiar with this scripting language, but managed to muddle around with things to make it work (as far as I can tell...... if it does something wonky I will post an update).

Hope this helps someone else! :)

Share this post


Link to post
  • 0

There are so many ways to do it but a simple and short way is to add a target="_blank" attribute to your links [anchor tags]. Whenever any user or visitor will click on that link, it will automatically open in a new tab or a window. to get technical help you can contact hnd assignments writer or facebook person.

Share this post


Link to post

Create an account or sign in to comment

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


×
×
  • Create New...