问题
Ive developed a Web Application that runs in my company's intranet. I had an issue with Internet Explorer's automatic compatibility mode earlier in my process, and added code to force my pages to be displayed in the newest version of IE:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
This worked perfectly. Until my web application was recently integrated into another intranet, available also to our customers. The web pages are beyond my control. My application is integrated within a frame inside another html page. And now I'm back to compatibility mode, and it breaks key functionality of my web app.
Is it possible to force the newest version of the browser to interpret only what is inside my frame?
回答1:
According to this & this (even better than the 1st - notice who marked the answer), a solution isn't possible.
If thinking about it for a second, IE's GUI is actually hinting that an entire page is rendered in compatibility mode (only 1 indicator icon per page, next to the address bar), so it's safe to assume everything is treated the same. Either full page compatibility, or not at all.
P.S. I know this isn't too helpful, but it's an attempt at providing a valid reason why it's not possible and it's better to start looking in different directions. Personally, I'd try to go with HTML5 (<!DOCTYPE html>
). That CAN be enabled selectively (only on your frame) and might not be too hard to adjust to since you already use 'edge'...
回答2:
This screenshot shows that IE Compatibility View can be overridden by a hosted frame.
The technique the frame uses here is to (1) inject an X-UA-Compatible header into the Host head, (2) via document.write(), and then (3) reload the Host page. It has the effect of boosting all frames in the page to the chosen level.
online demo
Prior to putting googledrive into Compatibility View, you'll notice the demo menu has no effect. It is unable to override any mode IE9 or higher, as they are "locked". IE8, IE7, and IE5 modes (and thus CV) are "unlocked" and can be overridden. That's the basis of the trick.
On the other hand, this following demo's Host page contains an X-UA-Compatible IE=5 (aka Quirks) header to start with. So the frame is able to override the Host mode even without putting googledrive into Compatibility View.
online demo (Host XUA=IE5)
The concept here is derived from this MS-Connect thread, which discusses IE-modes in iframes.
来源:https://stackoverflow.com/questions/30374898/can-i-disable-ie-compatibility-mode-only-for-content-within-a-frame