I have a question and maybe it is duplicate in this site but i can't find it!
I want to display this message
"Please open this website in firefox and you can download Mozilla Firefox from here"
when users open my web in IE.
How do it?
Thanks in advance.
you can use a conditional check
<!--[if IE]>
please open this web in firefox and you can download Mozilla Firefox from <a href='here'>here</a>
<![endif]-->
or you could try adding a js/programming check
If you prefer Javascript, you can check the userAgent.
if (navigator.userAgent.indexOf('MSIE')>0) {
document.write('do something');
};
MSIE is the indicator for Microsoft Internet Explorer
Related
I Want to: from chrome i want to launch google.com in IE.
Issue: when i run in chrome, google doesnt open. but if i am using IE, than google open up in IE
<Script>
function openURL(){
var shell = new ActiveXObject("WScript.Shell");
shell.run("iexplore http://google.com");
}
</Script>
<a onclick="openURL()" href=""> test </a>
The reason why this works in Internet Explorer (IE) and not Chrome is because ActiveXObject is not a web standard, and is only supported by IE. What you're asking for is unfortunately not possible at this time.
If this is just for you then you could create a custom protocol to open up internet explorer like you can do with the windows 10 calculator Calculator://
Then you would be able to launch it in plain html
Open Internet Explorer
Calculator example:
Open Calculator
https://support.shotgunsoftware.com/hc/en-us/articles/219031308-Launching-applications-using-custom-browser-protocols
You may also want to take a argument as a website to open somehow
I have some svg code that works in all browsers except IE. if i add this, it works in IE:
<canvas width="1900" height="1325" style="display:block;width:100%;visibility:hidden;"></canvas>
but it then messes up some stuff in all the other browsers. thus i tried to add this condition:
<!--[if IE]><canvas width="1900" height="1325" style="display:block;width:100%;visibility:hidden;"></canvas><![endif]-->
but then again it works in all browsers except IE, thus i think IE is treating it as a comment.
i can't figure out what's wrong, any help is much appreciated!
<!--[if ????]> only works in IE up to IE9.
IE10/11 treat it like it should be treated, a comment
to verify, open the developer tools in IE11
set IE to emulate "IE9" - and you'll see the conditional markup will be visible
switch back to 10/11 mode, and the content will again disappear
Important As of Internet Explorer 10, conditional comments are no longer supported by standards mode. Use feature detection to provide effective fallback strategies for website features that aren't supported by the browser. source
Is there a way in JAVASCRIPT (not jquery) to stop navigating a webpage in IE8 ?
( if i use jquery, a error appears : SCRIPT5009: jquery is not defined.).
In a company is still using IE8, They want to left behind little by little, so they need to send an ALERT when the user start navigating an specific webpage.
Note: Works perfectly in IE9 and Chrome
Regards
You can put scripts inside tags like this. These tags say run these scripts on versions of Internet Explorer that are below 9. So, you could write a script that posts a notice on your page about using outdated browsers.
<head>
<!--[if lt IE 9]>
<script src="outdated-browser-notification.js"></script>
<![endif]-->
</head>
On Android devices (I have tested Nexus 5, Nexus 10, Galaxy S4 and Galaxy Tab 3), the window.print() command in JavaScript doesn't do anything. As far as I can tell it doesn't even register an error.
I know for a fact that most if not all of these browsers can print because you can use mobile Chrome's menu to choose "print".
Why doesn't window.print() trigger the behavior you would expect (opening the clients print menu)? And is there an Android alternative to window.print()?
It is clearly stated in this Documentation, "The command is supported on iOS, Chrome on Windows and Safari and Chrome on Mac. It is not supported on Android."
Android phones don't have native support for printing yet, so window.print() will not work. Which means you need to use third-party app to do the printing. You could find some alternatives in this article.
I'm working on a simular problem and came up with this solution:
$(document).ready(function($) {
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
$('button.print').click(function(e) {
e.preventDefault();
if (isAndroid) {
// https://developers.google.com/cloud-print/docs/gadget
var gadget = new cloudprint.Gadget();
gadget.setPrintDocument("url", $('title').html(), window.location.href, "utf-8");
gadget.openPrintDialog();
} else {
window.print();
}
return false;
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<button class="print">Print this page</button>
I haven't had the time to check if this works, i don't have an android device with me at the moment. I Would love to have some feedback on this ;-)
⚠️ [Deprecated] : Google Cloud Print will no longer be supported as of December 31, 2020. Please see the support article for help migrating.
Use Google Cloud Print (GCP) - there is no app required. The user must have set up a printer via GCP though.
This example uses GCP gadget
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Print</title>
</head>
<body>
<div>
<p>On android devices (I have tested Nexus 5, Nexus 10, Galaxy S4 and Galaxy Tab 3) the window.print() command in javascript doesn't do anything, as far as I can tell it doesn't even register an error.</p>
<p>I know for a fact that most if not all of these browsers can print because you can use mobile chromes menu to choose "print". My questions is, why doesn't window.print() trigger the behavior you would expect (opening the clients print menu).
And is there an android alternative to window.print()?</p>
</div>
<div id="gcpPrint"></div>
<script src="https://www.google.com/cloudprint/client/cpgadget.js">
</script>
<script>
var gadget = new cloudprint.Gadget();
gadget.setPrintButton(cloudprint.Gadget.createDefaultPrintButton("gcpPrint"));
gadget.setPrintDocument("text/html", "Print", document.documentElement.innerHTML);
</script>
</body>
</html>
I think, direct print() method is disabled on devices by default. I not saw so many phones or other Android devices with printer, however by USB it should be possible of course.
Instead, recommended is saving content/page as pdf and print it via some cloud print service.
At this moment, window.print() functionality works perfectly on my Android 5.0.1 device with both, Chrome and the default browser.
Now, window.print() is working on Android devices.
Download adobe acrobat in your phone and you can use windows.print() in mobile.
I have been looking around and cannot find what I am looking for
I want to display a warning to IE users that my website does not support IE nor will it ever try to and that you should get a better browser.
How you detect IE is really all I need but it would be nice if someone told me how to trigger a lightbox on the page but I can do that myself if you don't include it
Thank's for the help!
Conditional HTML comments will work for detecting IE9 or less. From the HTML5 Boilerplate, which I highly suggest you use:
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please upgrade your browser or activate Google Chrome Frame to improve your experience.</p>
<![endif]-->
Try this
if ($.browser.msie) {
// you are using IE
}
More detail : jquery.browser
navigator object has all details related to browser and platform details of clients machine.
navigator.userAgent gives browser related details.
JS snippet:
<script>
var x = navigator.userAgent;
alert(' browser details ' + x);
</script>
Below link talks at length about it in detail :
http://www.javascriptkit.com/javatutors/navigator.shtml
Paste the code after tag:
<!--[if lt IE 8]>
<p class="browserupgrade">Vous utilisez un <strong>ancien navigateur</strong>. Mettez votre navigateur à jour dès aujourd'hui !</p>
<![endif]-->
PS: edit the content as you need. I translate it into French for my own use.