I'm looking for a way to make a SharePoint library preview fully functional with all types of documents using Javascript. So far the preview feature only works with images and PDF's.

This is the script I am using for my library to load the preview by clicking the icon types of each document.

function hookupToExpGroup() {
 var defaultExpCollGroupMethod = ExpCollGroup; 
 ExpCollGroup = function() {  
 defaultExpCollGroupMethod.apply(this, arguments);
function hookupToRefreshPageTo() {
 var defaultRefreshPageToMethod = RefreshPageTo; 
 RefreshPageTo = function() {  
 defaultRefreshPageToMethod.apply(this, arguments);
function insertClick(oLink, oImg) {
 oLink.id = "my_anchor_" + i;
 oImg.id = "my_hover_" + i;
 oImg.onclick = function() {
  var res = this.id.split("_");
  var lastIndex = res.length - 1;
  var anchorId = "my_anchor_" + res[lastIndex];
  href = document.getElementById(anchorId).href;
  var options = { url: href, width: 800, height: 600 };
function searchATags() {
 var aTagsTotal = document.links.length;
 for (i = 0; i   

Like I said it fully works on images and PDF's but if I were to click on any other type document, it gets stuck on the "Working On it" Screen when previewing.

Preview for images and pdf document types; works fine when icon is clicked preview for images and pdf file types works fine when icon is clicked Word, Excel and Powerpoint Document types don't work on preview Word, Excel and Powerpoint Document file types don't work on preview

Can Anyone explain or help, why is this happening and how I can adjust coding to make work or find the solution within SharePoint itself?

1 Answer 1


You need Office Web App for the script to be capable with any javascript.


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.