How to trigger 'quirks mode' is IE 10 - internet-explorer-10

Background:
The issue I'm facing is actually related to printing a webpage. The page is (almost) valid HTML 5 (with a few <table>s with cellpadding, and some <img>s without alts etc). I have a print stylesheet that prints nicely in all the browsers we are supposed to support (latest Chrome, FF and IE) except IE 10.
We have specific requirements about the print layout (which is significantly different from the web layout). We cannot use a separate page designed for printing as most of the page's content is generated using lots of inputs from the user within JavaScript. One of our print layout requirements is that the printout be on exactly 3 pages with specific parts on specific pages. Its working in all browsers we are supporting except IE 10.
In IE 10, the print out is 6 pages (3 in all others) working with the standard "Shrink To Fit" setting. Now I could go around writing a separate print stylesheet for IE 10 but that just seems like too much work.
While playing around with the IE 10 dev tools, I noticed that if I select "Quirks" "Document Mode" and then print, it fits nicely in 3 pages. So the simplest solution to my printing problem seems to be to somehow trigger quirks mode in IE 10 (but not in IE 11 where it already works).
The actual question:
So the question is, how do I trigger quirks mode in IE 10 without triggering it in IE > 10. This MSDN page says
If a page doesn't contain a <!DOCTYPE> directive, Internet Explorer displays the page in quirks mode by default.
So I tried doing the following with my doctype declaration:
<!--[if gt IE 10]>
<!DOCTYPE html>
<![endif]-->
That didn't trigger quriks mode in IE 10 for me. What will?

You can use a meta tag to controll how the page should render:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10">
This will cause the page to be rendered in IE10 mode if a DOCTYPE is present otherwise it will fallback to quirksmode. You can check this link to msdn to see the different X-UA-Compatible modes that can be used.
So if you want IE10 to always render the page in quirksmode you ought to be able to force it using:
<meta http-equiv="X-UA-Compatible" content="IE=5">

Related

What "magic" causes "cnn.com" when typed in IE11 to automatically launch Edge (Chromium)?

I just noticed that when I typed in "cnn.com" into the IE11 address bar (Windows 10), that it automatically launched the website in Edge (Chromium) instead, then rendered this bar at the top of the site in Edge.
(it also looked like if this was the only tab in IE, it auto closed IE)
I like this new behaviour to help migrate users over from IE, but sadly I could not detect how this is done code wise by CNN.
I looked in Fiddler, scanned the HTTP Headers, and the meta tags on the site... e.g.
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
and the IE only comment tags:
<!--[if lte IE 9]><meta http-equiv="refresh" content="1;url=/2.250.0/static/unsupp.html" /><![endif]-->
but I don't see anything specific that seems to be triggering this? I'd certainly like to entertain applying similar behaviour to some sites/apps that I work on.
FWIW, it also triggers (if you try it enough times) this message to remain in IE11:
https://support.microsoft.com/en-us/office/the-website-you-were-trying-to-reach-doesn-t-work-with-internet-explorer-8f5fc675-cd47-414c-9535-12821ddfc554?ui=en-us&rs=en-us&ad=us
Edge 87 installs a browser helper object called IEToEdgeBHO that performs this redirection based on a pre-provisioned site list (https://edge.microsoft.com/neededge/v1)
Inside Edge, see edge://settings/?search=Internet%20Explorer for the setting that enables/disables this feature.

IE11 issue with Embedded PDF

I have an HTML page that loads an embedded pdf on the page dynamically via an ajax call.
The below iframe code is pasted onto the Html page from the ajax method
<iframe src="${pdfpath}" width="1000" height="500">
It works well the first time it is called, however in subsequent calls there is an issue. The PDF loads fine, its the other contents on the page that disappears. This issue only happens in IE11, works fine in Chrome, Firefox and even IE9.
One thing odd I noticed is, when I open up the F12 developer tools, the remaining contents of the page appears again. Keep in mind that these contents have already been loaded the first time the page was loaded, the ajax method just inserts the iframe element onto the html page.
Below is a sample of how the ajax method inserts the data
$("#pdfDiv").empty().html(data);
Any help is appreciated on how to resolve this issue.
Thanks.
I was able to resolve this issue by replacing the iframe element with an object element
<object data="${pdfpath}" type="application/pdf">
<embed src="${pdfpath}" type="application/pdf" />
</object>
Thanks.
Since internet explorer 11 came up, everyone seems to have troubles when wanting to display or download pdf files, and me too. Personnaly, i just stopped using pdf. But, here is something for you, i don't know if it will help :
http://answers.microsoft.com/en-us/ie/forum/ie11-windows_7/internet-explorer-11-windows-7-pdf-files-will-not/3882b9cb-05ff-45de-acc6-0f6b8b752ed6?auth=1

Prevent a div from Google being read and followed without JavaScript

I don't want some of divs on my page to be followed by Google because they contain duplicate content from other websites, is this possible that I prevent those divs to be 'no-followed'?
I have seen this:
Methods for preventing search engines from indexing irrelevant content on a page
but its suggesting JavaScript for this purpose and I can't use JS in my case, also that question is from 2009, I hope things are bit changed now?
If you really do not want use javascript for this, the only way I'm sure will stop Google for index some content of your page is using iframe + robots noindex/nofollow.
Instead of use a div, create a normal iframe, in a way that it appears that is not a iframe.
To page that is target of iframe, add metatag robots <meta name="robots" content="noindex, nofollow">
Keep in mind that it will probably be interpreted as if it were adversing, so there will be some penalty, but this penalty may be lower than copying significant amount of content.

How to put the WebBrowser control into IE9 into standards?

i am using automation (i.e. COM automation) to display some HTML in Internet Explorer (9):
ie = CoInternetExplorer.Create;
ie.Navigate2("about:blank");
webDocument = ie.Document;
webDocument.Write(szSourceHTML);
webDocument.Close();
ie.Visible = True;
Internet Explorer appears, showing my html, which starts off as:
<!DOCTYPE html>
<HTML>
<HEAD>
...
Note: the html5 standards-mode opt-in doctype html
Except that the document is not in ie9 standards mode; it's in ie8 standards mode:
If i save the html to my computer first:
and then view that html document, IE is put into standards mode:
My question is how update my SpawnIEWithSource(String html) function to throw the browser into standards mode?
void SpawnIEWithSource(String html)
{
Variant ie = CoInternetExplorer.Create();
ie.Navigate2("about:blank");
webDocument = ie.Document;
webDocument.Write(html);
webDocument.Close();
ie.Visible = true;
}
Edit: A more verbose, less understandable or readable code sample, that doesn't help further the question might be:
IWebBrowser2 ie;
CoCreateInstance(CLASS_InternetExplorer, null, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IID_WebBrowser2, ie);
ie.AddRef();
ie.Navigate2("about:blank");
IHtmlDocument doc;
dispDoc = ie.Document;
dispDoc.AddRef();
dispDoc.QueryInterface(IHTMLDocument2, doc);
dispDoc.Release()
doc.Write(html);
doc.Close();
doc.Release();
ie.Visible = true;
ie.Release();
Update
Commenter asked on the ieblog entry Testing sites with Browser Mode vs. Doc Mode:
Can we get a description of how the document mode is determined when the HTML content is within an embedded webcontrol? Seems to be that the document mode is choosen differently - maybe for compatibility reasons?
MarkSil [MSFT] responded:
#Thomas: Thanks for raising that question. The WebBrowser Control determines the doc mode the same way that IE does because it contains the same web platform (e.g. there is one shared mshtml.dll across IE and WebBrowser Control hosts). The WebBrowser Control does default to the Compatibility View browser mode, which means that the default doc mode is IE7. Here is a blog post with more detail on this: blogs.msdn.com/.../more-ie8-extensibility-improvements.aspx.
To which Thomas responded:
#MarcSil (re: WebBrowser Control)
The problem with using registry entries to select document mode for WebControl is that it applies to the application as a whole. I write plugins for Google SketchUp where you have WebDialog windows to create UIs - it's just a WebBrowser control in a window. But that leads to problems as I want to force a document mode for my instance of the WebBrowser control, not for all of SU's WebBrowser controls as a whole.
So, my question is: how do you control the document mode per instance for a WebBrowser control?
Have you tried setting in your html the
<meta http-equiv="X-UA-Compatible" content="IE=9" />
or
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
which means latest version
The IE9 "version" of the WebBrowser control, like the IE8 version, is actually several browsers in one. Unlike the IE8 version, you do have a little more control over the rendering mode inside the page by changing the doctype. Of course, to change the browser mode you have to set your registry like the earlier answer. Here is the location of FEATURE_BROWSER_EMULATION:
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
SOFTWARE
Microsoft
Internet Explorer
Main
FeatureControl
FEATURE_BROWSER_EMULATION
contoso.exe = (DWORD) 000090000
Here is the complete set of codes:
9999 (0x270F) - Internet Explorer 9.
Webpages are displayed in IE9
Standards mode, regardless of the
!DOCTYPE directive.
9000 (0x2328) - Internet Explorer 9. Webpages containing standards-based !DOCTYPE
directives are displayed in IE9 mode.
8888 (0x22B8) -Webpages are
displayed in IE8 Standards mode,
regardless of the !DOCTYPE directive.
8000 (0x1F40) - Webpages containing
standards-based !DOCTYPE directives
are displayed in IE8 mode.
7000 (0x1B58) - Webpages containing
standards-based !DOCTYPE directives
are displayed in IE7 Standards mode.
The full docs:
http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation
FEATURE_BROWSER_EMULATION does not works with CoInternetSetFeatureEnabled. The documentation of INTERNETFEATURELIST is not updated since IE7.
Since the feature setting is under HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl you may be able to override the value in your process via a registry API hook.

Is there a workaround to Safari's/Opera's bug that you can't tab through hyperlinks?

In IE, Firefox, Chrome and most Windows-based interfaces that I've used, the Tab key can be used to navigate from one form field or hyperlink to the next (e.g. "actionable" items) (note: I have not tested on other Operating Systems)
However Safari and Opera skip all hyperlinks in a web page when tabbing. IMHO its a usability bug but I digress.
Is there a workaround/hack to make Safari and/or Opera navigate through these links?
I've noticed that Opera will accept the tabindex attribute if set e.g. tabindex="0" thus maintaining the links "index" within the flow of the DOM on the page... but Safari does not want to accept this.
For those interested, this bit of jQuery will make all the hyperlinks tabbable.
//Make links 'tab-able' in Opera
$(document).ready(function(){
if($.browser.opera){
$('a[href]').attr('tabindex', 0);
}
});
...and although this seems to work for Opera... is there a better workaround?
In Safari, it's not a bug, it's an optional feature. On the Mac, tab selects objects other than links, Option+Tab select all objects. You can swap the behavior of these shortcuts in Preferences->Advanced. Then tab will behave like in other browsers.
On Windows, Option+Tab is not available. By default tab selects objects other than links , but there is an option in Preferences->Advanced that makes tab select all objects. Then tab will behave like in other browsers.
You should probably not try to interfere with this, as you would interfere with the user's preferences.
Actually this is a bug, according to the spec (see below) anchors (<a> elements) are supposed to accept the tabindex property, and a tabindex of 0 should make it focusable in the order the elements appear in the document.
http://www.w3.org/TR/html401/interact/forms.html#adef-tabindex
Opera traditionally thought this was a feature, not a bug (we had and have other key shortcuts for navigating links, when you know those you might find it useful to have distinct navigation for links and form elements - tried shift+arrow spatial navigation yet?). To some people it still is a feature. True anecdote: once upon a time an internal build made links tab'able by accident and this caused so many bug reports and complaints it was promptly reversed. (As far as I remember, also because the tabbing was buggy in other ways).
We know, however, that tabbing to links is something most users expect and that we should implement a pref for this like Safari has. In the meantime, you can add something like your JS fix above to a user javascript to have tab navigation to links on all websites out there.