We have a lot of old Infopath forms in an old Sharepoint 2010 website that runs in IE11. They want the site running in IE9 or above so we can run youtube videos. As far as everything other than Infopath forms, IE9-IE11 functions fine for our uses. The problem is that the Infopath forms will not open in any browser other than IE8. I believe it is something to do with the code triggered on the click of Infopath links being written for IE8, and not working in later versions.
I tried writing javascript that checks the page for any .xsn text (all of the links to Infopath files have .xsn in the link text), and if it finds it, it dynamically injects a tag into the to force IE8 Compatibility mode on. This obviously didn't work, as the browser had already read the meta info and ran in default IE11 mode. So, I tried an experiment using localStorage to see if it is at all possible to have javascript write in an x-ua-compatible meta tag before the browser chose its default version of IE11. Basically the code checks the page for .xsn text, and if it finds it, sets a localStorage property to true, then triggers a browser reload. Another piece of code checks localStorage for that property value, and if it is true, renders the x-ua-compatible meta tag into the . The code works as far as getting/setting the localStorage property correctly, and rendering the correct x-ua-compatible meta tag. I check the HTML after page load, and the meta tag is changing to IE compatibility mode on any page that has an Infopath form on it. However, it seems like the browser has already chosen it's version mode prior to that meta tag being written into the .
/**************************************************
script to insert meta tag to toggle
IE versions on the fly if Infopath forms
have been detected on the page
**************************************************/
if (localStorage.getItem('XSN-detect') !== null) {
//check localstorage for XSN-detect prop value
//if false, set meta tag to emulate IE11
if (localStorage.getItem('XSN-detect') === 'false') {
var link = document.createElement('meta');
link.setAttribute('http-equiv', 'x-ua-compatible');
link.content = 'IE=11';
document.getElementsByTagName('head')[0].appendChild(link);
}
//check localstorage for XSN-detect prop value
//if true, set meta tag to emulate IE8
if (localStorage.getItem('XSN-detect') === 'true') {
var link = document.createElement('meta');
link.setAttribute('http-equiv', 'x-ua-compatible');
link.content = 'IE=EmulateIE8';
document.getElementsByTagName('head')[0].appendChild(link);
//alert('This page contains Infopath forms, which requires IE8. Please press ok to have the page reload in IE8 mode.');
}
}
$(function() {
if (localStorage.getItem('XSN-detect') === null && document.getElementsByTagName('BODY')[0].innerHTML.indexOf('.xsn') != -1 || localStorage.getItem('XSN-detect') !== 'true' && document.getElementsByTagName('BODY')[0].innerHTML.indexOf('.xsn') != -1) {
localStorage.setItem('XSN-detect', 'true');
window.location.reload();
}
if (document.getElementsByTagName('BODY')[0].innerHTML.indexOf('.xsn') == -1) {
localStorage.setItem('XSN-detect', 'false');
}
});
I really just need to know if it is possible to dynamically change the x-ua-campatible meta tag and have the IE browser catch it before it chooses its version to load. I don't have access to update the C# or the config, so I am stuck with the front end.