Does HTML5 work in a .hta file? - javascript

I am trying to understand what the main difference between hta and html files is. I googled it and I found this:
The main problem is that javascript is buggy. For example the
javascript: protocol does not even exist. Hta seems to prefer VBscript
modeled coding instead of the javascript model, such as
<span style="cursor:hand" onclick=go()> instead of
<a href="#" onclick=go()>. It's a windows exe so some
cross-browser/cross-platform contructs of html are simply not
supported or ill-supported. Also window resizing produces different
dimensions.
I have some interactive plots (HTML5) generated by JavaScript codes. Are they gonna be functional if I transfer them to hta files?

If you don't add any special code, the answer is no.
Usually, HTML5 doesn't work in HTA files because they are run by mshta.exe which acts like IE7 and HTML5 isn't supported in earlier versions of IE than IE9. But if you add <meta http-equiv="x-ua-compatible" content="ie=edge" /> in the head of the HTA, the HTA will act like the version of IE installed on the computer, so if the computer has IE9 or later and you add that tag, it will work. The problem with this is that if you upgrade the HTA, the <hta:application/> tag won't have any effect so you will lose all effects like icons, window properties, etc. For this reason, I prefer to not upgrade the HTA and to use workarounds instead of HTML5.

In HTA, to get the code to properly work, you must include the tag <meta http-equiv="x-ua-compatible" content="ie=edge" /> or <meta http-equiv="x-ua-compatible" content="ie=9">to get the JavaScript and HTML 5 to work completely. You may add
<HTA:APPLICATION
APPLICATIONNAME="HTA"
ID="HTA"
VERSION="1.0"
MAXIMIZEBUTTON="no"/>
Or some variant of that to get the HTA window to work properly. If you would post the code, Hamid K, that you are referring to, I would check it for you to more thoroughly answer the question.

Related

IE8 site keeps going into Quirk mode with JS added into the page

We have a site that's running perfectly in all browsers except IE8.
What happens is that it falls into Quirks mode forcefully by the browser due to the reason unknown to me.
And yes, it breaks the site really bad.
What's more weird is that it adds somekind of JS on its own to the code (when checked through View Source.
This is what it's showing:-
<SCRIPT language="JavaScript">
<!--
document.cookie = "IV_JCT=%2Fapchannel-lop; path=/";
//-->
</SCRIPT>
<!DOCTYPE html>
<html lang="en">
<head profile="http://www.w3.org/1999/xhtml/vocab">
<meta http-equiv="x-ua-compatible" content="IE=Edge"/>
...
The <SCRIPT> in the start is not added by me and is being added by IE8.
I have tried the following
First line <!DOCTYPE html> and then right after <head>, I wrote <meta http-equiv="x-ua-compatible" content="IE=Edge"/>
Adding respond
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
Nothing works.
Any idea how I can stop this and just force it to load with IE8 standard mode?
Thanks
The problem is that you're adding the script before the <!DOCTYPE>.
The doctype must be the very first thing on the page, otherwise IE will go into quirks mode. (even blank lines at the top of the page have been known to affect this)
Move your script somewhere else in the page, ideally inside the <head> element, and ensure that you have valid HTML markup, and the problem will resolve itself.
IE 8 will not mangle HTML like that. Something else must be responsible.
From AJAX techniques within a Tivoli Access Manager WebSEAL Environment:
Junction cookies
Issue
When you create a WebSEAL junction using the -j option to enable
junction cookies, special HTML code is inserted at the beginning or
end of the HTTP response that sets the correct cookie path in the
browser (the location determined by the -j option). Generally, the
returned page will look similar to that in Listing 11.
Listing 11. Example of junction cookie insertion
<SCRIPT>
document.cookie = "IV_JCT=%2Fjunction_name";
</SCRIPT>
<html>
<title>Example page </title>
<body>
Rest of the document...
.
.
.
That's a pretty specific bit of JavaScript (Debugging tip: When weird variable names show up in your code and you don't know where they came from: Type them into Google), so its a reasonable bet that this is what is responsible.
It doesn't sound like there is a work around, so your options seem to come down to:
Stop using IE 8. It is unsupported by Microsoft and no supported operating system that can run it can't be upgraded to a newer version of IE (they could also be upgraded to a non-IE browser).
Stop using WebSEAL (or at least WebSEAL junctions using the -j option) since it invalidates your HTML.

How to set IE 11 enterprise mode to standard mode using javascript or PHP?

I tried a lot for Ckeditor not working when I changed IE 11 standard to Enterprise mode.
I have set below in header for document mode but it does not seems:
<meta http-equiv="X-UA-Compatible" content="IE=8">
So I have substituted idea to turn off the enterprise mode while the page being load but i did not get any javascript code to turn off mode while page load.
Please suggest if any idea to turn off Enterprise mode using java script it would be great helpful.
I used TinyMCE editor instead of Ckeditor it has been worked fine.
Then i could used the meta header below tag:
<meta http-equiv="X-UA-Compatible" content="IE=8,IE=9,IE=7">
Still the TinyMCE completable with All IE browser.

Meta tag in JavaScript and Html scripts assuring web browser compatibility

I would like to get some advice regarding including meta tag assuring compatibility with IE 8. The thing is that my html code contained meta tag:
http-equiv="X-UA-Compatible" content="IE=8"
However it did not work because before the line with meta tag some javascripts had been running by the application in response render method:
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
response.render(CssHeaderItem.forReference(new CssResourceReference(BasePage.class, "CSSPage.css")));
}
So that the line with meta tag conforming the web browser compatibility had been placed further, not at the first place, so in consequence ignored.
I was trying to put some javaScripts lines in the code which were supposed to put meta tag at the beginnig of the html script:
$(document).ready(function(){
var meta = '<meta http-equiv="X-UA-Compatible" content="IE=8" />';
document.head.insertAdjacentHTML('afterbegin', meta);
});
It did not work either.
I would be grateful for any advice how to improve the code to make it compatible with desired web browser version: IE 8.
Cheers and Thanks,
JaneElle
It did not work either.
I would be grateful for any advice how to improve the code to make it compatible with desired web browser version: IE 8.
Cheers and Thanks,
JaneElle
Having <meta http-equiv="X-UA-Compatible" content="IE=8" /> in your page doesnt make it compatabile with that browser, I think you are confused on the usage.
The idea behind compatibility mode is to allow web sites and applications that are not designed to modern standards to continue to work while upgrades can be made, allowing end users to upgrade to the latest browser version.
read up on x-ua compatability here.

IE Compatibility mode change using javascript

Hi my aspx page is having some third party controls and those are not appearing when I upgrade my IE version to 11. Till IE10 everything was worked fine.
And when I change my compatibility mode of my IE like this http://winaero.com/blog/how-to-enable-compatibility-view-in-internet-explorer-11-ie11/
my controls are working fine. But I cant ask my end user to do the same.
Is there any way to handle this? I tried by adding below tag in section of my page.
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9"/>
But it is not working. Can some one tell me how to handle this through code?
It's just IE=9, not IE=EmulateIE9:
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
More here: How to Use X-UA-COMPATIBLE.
Of course, I would also look at migrating to new or different controls that work properly with a modern engine. Quote from the article above:
It is not a best practice to let issues like the example linger as your application is at risk of falling even further behind as web standards progress.

What is the best way to determine if a web-page is for mobile?

Should I scan for tags in the html code? Or what? What determines whether a page is optimized for mobile?
One option is to scan for tags. If so, what other tags are there?
<link rel="apple-touch-icon" href="..." />
<meta name="viewport" content="width=device-width, user-scalable=no" />
Another option is to see if the HTML returned from a mobile user-agent is smaller than the HTML returned from a desktop browser. user agent...
Any thoughts?
One option: look for: <meta name="MobileOptimized" />
Another: <meta name="HandheldFriendly" content="true"/>
Another: doctype is either XHTML-MP or WML (or other mobile-friendlies).
Here's a usefuil link for sniffing out different smartphones using JavaScript.
http://www.hand-interactive.com/resources/detect-mobile-javascript.htm
However, its worth paying attention to the caveats in the above link. Particularly, the fact that we are browser sniffing, which is inherently unreliable (I recently got a hit on my website for MSIE 999.1)
What exactly are you trying to accomplish?
Officially, there is no such thing as a mobile page. It's perfectly possible to create a page that works equally well on mobile as on desktop browsers. Hell, if you just make a page with simple html and no styling it will already do that.
These days we often see seperate mobile pages, but usually this is an indicator that the design of the 'normal' page was not thought-through.
Long story short, you could never detect this 100% because there's no real difference.
If you want to find out whether or not a browser is mobile or not, check this out: http://wapl.info/coding-for-the-mobile-web-with-WAPL/chapter/isMobileDevice-via-CURL/
Pass through all of your headers, and the web service will do the rest.
Better than detecting mobile with javascript, or looking for specific tags - do it before you even start outputting anything to the screen.

Categories

Resources