Is there any benefit of using html5shim library over document.createElement('header')? - javascript

What is difference between using
<!--[if IE]>
<script>
document.createElement('header');
document.createElement('footer');
document.createElement('section');
document.createElement('nav');
</script>
<![endif]-->
instead
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

I believe that the HTML shim library also includes the IE print Protector

Related

How can I make a button hidden only when the user is browsing with IE using javascript

Here is my code.. I want to hide the button if the user is browsing with IE.
I tried like this but it's not working can any one help me out.
<!DOCTYPE html>
<html>
<head>
<script>
var lang = navigator.systemLanguage;
if (lang!='en-US'){
document.write("Well, this is not internet explorer");
} else{
document.write("This is internet explorer");
document.getElementById('btn1').style.visibility='hidden';
}
</script>
</head>
<body>
<p>This is a paragraph.
</p>
<button class="btn1">Input</button>
</body>
</html>
You may try conditional comments, without javascript:
<!--[if IE]>
<button>Not for IE</button>
<![endif]-->
And more:
<!--[if IE]>
According to the conditional comment this is IE<br/>
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br/>
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br/>
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br/>
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br/>
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br/>
<![endif]-->
<!--[if lt IE 9]>
According to the conditional comment this is IE lower than 9<br/>
<![endif]-->
<!--[if lte IE 7]>
According to the conditional comment this is IE lower or equal to 7<br/>
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is IE greater than 6<br/>
<![endif]-->
<!--[if !IE]> -->
According to the conditional comment this is not IE 5-9
<br/>
<!-- <![endif]-->
There are many ways to do that, there two of them:
Using CSS:
Add the below css class into your button and make it hide for IE browser, like
<!--[if gt IE 7]>
<style>.hideBtn{display:none}</style>
<!--<![endif]-->
Using Javascript:
window.navigator, by finding the browser version, make it hidden
document.getElementById('btn1').style.display = 'none';
thanks for your help i found the solution .
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9">
<!--[if IE]>
<style>.hideBtn{display:none}</style>
<![endif]-->
<script>
var lang = navigator.systemLanguage;
if (lang!='en-US'){
document.write("Well, this is not internet explorer");
} else{
document.write("This is internet explorer");
}
</script>
</head>
<body>
<p>This is a paragraph.
</p>
<button class="hideBtn" id ="hideBtn">Input</button>
</body>
</html>

How to write advanced conditions in RequireJS?

How to write custom conditions in including JavaScript files using RequireJS?
Example:1
if("ontouchend" in document) document.write("<script
src='/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
Example:2
<!--[if lt IE 9]>
<script src="/js/html5shiv.js"></script>
<![endif]-->
Currently I am using shim and paths. Is there any room to place this. Is it possible?
You could use a conditional specific class on the html element itself, then checking for it and loading the dependencies will be easier in the inside your existing script.
For Example:
<!--[if lt IE 7]> <html class="ie lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="ie lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="ie lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html class="ie"> <![endif]-->
<html>
And in your script, you could try something like:
if ($('html.lt-ie9').size()) {
require(['/Scripts/ieSpecificScripts'], function(ieScript) {
// ... do stuff
});
}else
{
...
}
Happy Coding.. :)

how not loading javascript code in lt IE 9

i use javascript code in project and i want not load this code in lt IE 9. i use this code but its not working:
<!--[if lt IE 9]>
<script type="text/javascript">
....
</script>
<![endif]-->
<!--[if !lt IE 9]>-->
...
<!--<![endif]-->
You can visit this microsoft article to learn how to build more complex conditional comments
try this:
<!--[if gte IE 9]>-->
...
<!--<![endif]-->
<!-- Target IE 8 and lower -->
<!--[if lt IE 9]>
<script type="text/javascript">alert('hello world');</script>
<![endif]-->
So perhaps give this a try:
<!-- Target IE 9 and lower -->
<!--[if lt IE 10]>
<script type="text/javascript">alert('hello world');</script>
<![endif]-->

How to prevent javascript library load for IE8

How to prevent the load of the D3 library for IE8 (and below) ?
<head>
<script src="../lib/d3/d3.v2.min.js" type="text/javascript"></script>
</head>
<head>
<!--[if !IE || gte IE 9]><!-->
<script src="../lib/d3/d3.v2.min.js" type="text/javascript"></script>
<!-- <![endif]-->
</head>
<!--[if gt IE 8]>
<script src="../lib/d3/d3.v2.min.js" type="text/javascript"></script>
<![endif]-->

'G_vmlCanvasManager' is undefined

I am using the highcharts charting library,
i am including excanvas if the browser is ie using
<!--[if IE]>
<script type="text/javascript" src="<script type="text/javascript" src="excanvas.compiled.js"></script>
<![endif]-->
yet i still get
'G_vmlCanvasManager' is undefined
is it a typo?
yours is
<!--[if IE]>
<script type="text/javascript" src="<script type="text/javascript" src="excanvas.compiled.js"></script>
<![endif]-->
should it be?
<!--[if IE]>
<script type="text/javascript" src="xcanvas.compiled.js"></script>
<![endif]-->
I also get this error. It was a I was referencing 'G_vmlCanvasManager' in my javascript instead of 'window.G_vmlCanvasManager'

Categories

Resources