I have one picture library, where several pictures are stored. In that picture library I want to put such a link that will download selected images.

To achieve this functionality, I thought to prefer put one content editor web part in which place one hyperlink that will redirect to the custom application page with selected item ids in query string parameters.

I searched over internet and couldn't find any proper solution.

How to get the selected items in the JavaScript or is there any way to achieve functionality to download multiple links. The site is anonymous so the option of placing custom action would not be possible.

1 Answer 1


Here is a basic example of how to get the selected items with javascript:

var items = SP.ListOperation.Selection.getSelectedItems();
var myItems = '';
var i;

myItems = items.map(function (v) {
    return '|' + v.id;

Complete code for opening a modal page passing in list id and selected items:

function resultCallback(result, value) {

var items = SP.ListOperation.Selection.getSelectedItems();
var myItems = '';

myItems = items.map(function (v) {
    return '|' + v.id;

if (myItems !== '') {
    var options = {
        url: '{SiteUrl}/_layouts/MyPage.aspx?Items=' + myItems + '&ListId={SelectedListId}&Source={Source}',
        tite: 'My Page',
        allowMaximize: false,
        showClose: true,
        width: 500,
        height: 160,
        dialogReturnValueCallback: resultCallback


From here.

But I would encourage you to use a Custom Action instead of a Content Editor webpart if you have the possibility. (The link that is source of the code also contains an example (but for 2010))

  • Thanks for the answering sir, For my knowledge I am asking you that, will the custom action appear to the user of anonymous site?
    – users1100
    May 9, 2014 at 7:19
  • Not anonymous users, since they will not see ribbon. So if that is the object, you may be on the right path :) May 9, 2014 at 7:20
  • The ids are successfully fetched using first piece of code. Thank you sir. :-)
    – users1100
    May 9, 2014 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.