I have an HTML page that has a number of links displayed via dropdowns / unordered lists on top of the page (using a Bootstrap 3 navbar). These links go to MS Office documents (Word, Excel, PowerPoint) that are hosted on an internal server.
By click on the links I would like to have them open within an iframe on the same page instead of using separate pages or downloads.
I tried the below but this always opens me the standard popup to either save the file or open it in a separate window.
Can someone tell me what I am doing wrong here? E.g. something in addition to refresh the iframe?
My HTML for the link dropdown (just one item):
<li type='disc'><a href='javascript:void' class='navLink' name='test.pptx'>Text</a></li>
My HTML for the iframe:
<iframe src="#" width="100%" height="auto" frameborder="0" id="iView" name="iView"></iframe>
My jQuery:
$(document).on('click', '.navLink', function() {
var fileName = $(this).attr('name');
var fileLocation = 'http://somefilepath/uploads/';
var fileSource = fileLocation + fileName;
$('#iView').prop('src', fileSource);
});
Edit
If this approach does not work is there a way to embed an MS office document in an HTML website?