johnnydoe Posted June 21, 2016 Share Posted June 21, 2016 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 More sharing options...
teppo Posted June 21, 2016 Share Posted June 21, 2016 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. 1 Link to comment Share on other sites More sharing options...
johnnydoe Posted June 21, 2016 Author Share Posted June 21, 2016 Hi teppo, thanks for your reply! I now took the javascript road. With jQuery I search for all links which have 'assets/files' in their href and attach target="_blank" to them. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now