How to set attachment download with new tab

Home Forums Legacy Support Support queries How-to & Troubleshooting How to set attachment download with new tab

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #120058
    Eric
    Spectator
    Hi there, How to set attachment downloading with new tab in unit? If I download like PDF, by default, it will open in the same window instead of downloading .
    #120143
    H.K. Latiyan
    Participant
    Try adding the bellow code in your wplms-customizer.php file present in your wplms customizer plugin: add_action('wplms_after_start_course',function(){   ?>   <script>     jQuery(document).ready(function(){       jQuery('.unitattachments #attachments a').attr('target','_blank');     });   </script>   <?php });
    #120146
    Eric
    Spectator
    I tried this code looks not working.
    #120237
    H.K. Latiyan
    Participant
    It seems like you are using the ajax in course status page, then instead of the above code use the bellow code: add_action('wplms_after_start_course',function(){   ?>   <script>     jQuery(document).ready(function(){       jQuery('.unit_content').on('unit_traverse',function(){         jQuery('.unitattachments #attachments a').attr('target','_blank');       });     });   </script>   <?php });
    #120243
    Eric
    Spectator
    still not working. I have setting: Ajax disabled in course unit loads
    #120252
    H.K. Latiyan
    Participant
    If the ajax is disabled then the first code I shared works fine . Where are you adding the code ? It works fine on my test setup.
    #120259
    Eric
    Spectator
    I tried two codes still not working, I add to customizer plugin.   check the html code, no "<b style="box-sizing: border-box; color: #4b4d4d; font-family: Lato; font-size: 14px;">_blank</b>", perhaps can you suggest me which original file I can edit.
    • <i class="fa fa-file-pdf-o"></i>
    #120285
    H.K. Latiyan
    Participant
    There is no js file to edit because this is not available in wplms, the above script is a simple js trick to open any link in the new window tab.
    #120286
    H.K. Latiyan
    Participant
    Try coping only the code inside the script tag (including script tag) from the above code and then add it in the wplms->footer->google analytics code. Let me know if it works from there.
    #120307
    Eric
    Spectator
    still not working. just confirm can it work on your side? Are you using a pdf as attachment?
    #120395
    H.K. Latiyan
    Participant
    Yes I am using a pdf, refer this video: http://screencast-o-matic.com/watch/cbiX1dlqhH
    #120406
    Eric
    Spectator
    Hi, I am using modern theme, can you try use modern theme?
    #120421
    H.K. Latiyan
    Participant
    Hi.. You are using modern theme, I didn't know about it. The modern theme has different course status page and the hook is different in modern theme. For modern theme with ajax disabled in course status page you can use the bellow code: add_action('wplms_course_start_after_timeline',function(){   ?>   <script>     jQuery(document).ready(function(){       jQuery('.unitattachments #attachments a').attr('target','_blank');     });   </script>   <?php });
    #120427
    Eric
    Spectator
    That's great. many thanks. it works now. Btw, I have another problem, when I set the Unit Duration parameter as "seconds", but the the course status page on left-up corner is still for mins, how can I resolve. I am using modern theme
    #120454
    H.K. Latiyan
    Participant
    Hi... Please create new topics for new issues. I am unable to replicate the duration issue on my test setup, refer: http://prntscr.com/fu90ne
Viewing 15 posts - 1 through 15 (of 16 total)
  • The topic ‘How to set attachment download with new tab’ is closed to new replies.