Jump to content

Opening links to files automatically in new tab


johnnydoe
 Share

Recommended Posts

Hi there!

With the module "Page Edit Link" I can make settings so that links to external websites open in a new tab automatically, which is very handy. Now I want to do the same with links that point to files, so that the files (jpgs and pdfs) are opened in a new tab too. It seems not to be possible with "Page Edit Link". Is there another way? I know, the page editors could set the "_blank" value each time manually, but this doesn't seem to be very efficient to me. Any ideas?

Thanks in advance!
Jonas

Link to comment
Share on other sites

Was literally thinking about the same thing just yesterday. Solved it by a combination of JavaScript targeting only links to assets and instructing users to apply target "_self" to file links they don't want to open in a new window/tab. That's definitely less intuitive than having target "_blank" automatically selected, but does the trick :)

Another option would be injecting JavaScript for when Page Edit Link is rendered and handling this there. In that case it would probably make sense to track the change event of the file input and act on that, perhaps combined with a check that avoids changing the target value if the user has already changed it manually.

Just for the record, it would be nice to see a built-in setting for this. I'd assume this to be a relatively common need.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

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

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...