Reputation: 1040
I have a excel file I turned into a .mht file, and I am embedding it successfully in a html page using iframe. Now the excel file has hyperlinks inside it. I am wondering If I can have it to where when a person clicks on a hyperlink inside the excel file it will open up a new tab in the web browser or just open up a new browser window. Can this be done through coding inside the iframe or do I have to do some kind of coding inside the excel file ?
Posting what the html code is if I can edit it or add a property to it if someone knows. Maybe I may need to use something besides iframe to get it to work on a html page.
<iframe src="LinktoFile.mht" width="100%" height="100%"></iframe>
Upvotes: 1
Views: 2566
Reputation: 28563
any file that you convert/ save as from excel can easily be edited (using notepad even). ADvisable that you removable the microsoft auto-generated css, but the main thing is that you add a target ="_blank
in your hyperlink html. This will make the hyperlinks open in a new window.
I know it works with html files but i don't see why mht files should differ greatly (and besides, why make life more difficult? Just save as a html file..)
Upvotes: 1
Reputation: 22247
I read that .MHT is a "Mime HTML" file, a kind of html archive. The browser support for it seems limited. If you're ok with that read on...
As long as the parent html file and the mht file are on the same domain, you might be able to add to/modify the DOM of the mht file. I don't know for sure.
Here is a test you can try. Modify your iframe tag with an id, and then put the script block right after it. The result should be that all tags in the iframe open in a new tab. If that doesn't happen please check the browser console for any errors and report back.
<iframe id='xl' src="LinktoFile.mht" width="100%" height="100%"></iframe>
<script>
$('#xl').on('load', function () {
$('#xl').contents().find('a').attr('target', '_blank');
});
</script>
Upvotes: 1