Here is what I would do to debug and find the root cause:
- Open the page in Firefox (suggestion, it can be any browser with a JS console, I usually use Firebug)
- Open the Console
- Manually call the function in the Console:
SP.ListOperation.Selection.getSelectedItems(SP.ClientContext.get_current())
- Check if any value is returned
- If there is no value, my suggestion would be to wrap the whole function in ExecuteOrDelayUntilScriptLoaded (as maybe SP.js isn't loaded for some reason): ExecuteOrDelayUntilScriptLoaded with sp.js when in debug mode Object ExpectedExecuteOrDelayUntilScriptLoaded with sp.js when in debug mode Object Expected
- If there is a value, then the problem relies in other parts of your function
- Continue by typing
redirectToDownloadsPage(no parenthesis, just to see if the function exists) - Is the function registered on the client side?
- If it is, call it by doing
redirectToDownloadsPage() - Does it work now?
https://developer.mozilla.org/en-US/docs/Debugging_JavaScript