EzDevInfo.com

internet-explorer interview questions

Top internet-explorer frequently asked interview questions

Why Javascript only works after opening developer tools in IE once?

IE9 Bug - Javascript only works after opening developer tools once.

Our site offers free pdf downloads to users, and it has a simple "enter password to download" function. However, it doesn't work at all in Internet Explorer.

You can see for yourself at this example: http://www.makeuseof.com/pages/how-to-use-virtual-box

The download pass is "makeuseof". In any other browser, it works fine. In IE, the buttons both just do nothing.

The most curious thing I've found is that if you open and close the developers toolbar with F12, it all suddenly starts to work.

We've tried compatibility mode and such, nothing makes a difference. Please, help me figure this out!

How do I make this work in Internet Explorer?


Source: (StackOverflow)

How do I make background-size work in IE?

Is there any known way to make the CSS style background-size work in IE?


Source: (StackOverflow)

Advertisements

How to prevent a jQuery Ajax request from caching in Internet Explorer?

How do I prevent a jQuery Ajax request from caching in Internet Explorer?


Source: (StackOverflow)

Do HTML5 custom data attributes “work” in IE 6?

Custom data attributes: http://dev.w3.org/html5/spec/Overview.html#embedding-custom-non-visible-data

When I say “work”, I mean, if I’ve got HTML like this:

<div id="geoff" data-geoff="geoff de geoff">

will the following JavaScript:

var geoff = document.getElementById('geoff');
alert(geoff.dataGeoff);

produce, in IE 6, an alert with “geoff de geoff” in it?


Source: (StackOverflow)

Why don't self-closing script tags work?

What is the reason browsers do not correctly recognize:

<script src="foobar.js" /> <!-- self-closing script tag -->

Only this is recognized:

<script src="foobar.js"></script>

Does this break the concept of XHTML support?

Note: This statement is correct at least for all IE (6-8 beta 2).


Source: (StackOverflow)

What's the difference if exists or not?

What's the difference if one web page starts with

<!DOCTYPE html> 
<html> 
  <head> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 

and If page starts with

<!DOCTYPE html> 
<html> 
  <head> 
     <!-- without X-UA-Compatible meta -->

If there is no difference, I suppose I can just ignore the X-UA-Compatible meta header, since I just want it to be rendered in most standard mode in all IE versions.


Source: (StackOverflow)

event.preventDefault() function not working in IE

Following is my javascript (mootools) code:

$('orderNowForm').addEvent('submit', function (event) {
    event.preventDefault();
    allFilled = false;
    $$(".required").each(function (inp) {
        if (inp.getValue() != '') {
            allFilled = true;
        }
    });

    if (!allFilled) {
        $$(".errormsg").setStyle('display', '');
        return;
    } else {
        $$('.defaultText').each(function (input) {
            if (input.getValue() == input.getAttribute('title')) {
                input.setAttribute('value', '');
            }
        });
    }

    this.send({
        onSuccess: function () {
            $('page_1_table').setStyle('display', 'none');
            $('page_2_table').setStyle('display', 'none');
            $('page_3_table').setStyle('display', '');
        }
    });
});

In all browsers except IE, this works fine. But in IE, this cause error. I have IE8 so while using its javascript debugger, I found out that the event object does not have a preventDefault method which is causing the error and so the form is getting submitted. The method is supported in case of firefox (which I found out using firebug).

Any Help?


Source: (StackOverflow)

How to get started with developing Internet Explorer extensions?

Does anyone here have experience with/in developing IE extensions that can share their knowledge? This would include code samples, or links to good ones, or documentation on the process, or anything.

I really want to do this, but I'm hitting a giant wall with lousy documentation, lousy code/example code/lack thereof. Any help/resources you could offer would be greatly appreciated.

Specifically, I would like to start with how to get access to/manipulate the DOM from within a IE extension.

EDIT, even more details:

Ideally, I would like to plant a toolbar button that, when clicked, popped a menu up that contains links to external sites. I would also like to access the DOM and plant JavaScript on the page depending on some conditions.

What is the best way to persist information in an IE extension? In Firefox/Chrome/Most modern browsers, you use window.localStorage, but obviously with IE8/IE7, that's not an option. Maybe a SQLite DB or such? It is okay to assume that .NET 4.0 will be installed on a user's computer?

I don't want to use Spice IE as I want to build one that is compatible with IE9 as well. I've added the C++ tag to this question as well, because if it's better to build one in C++, I can do that.


Source: (StackOverflow)

Override intranet compatibility mode IE8

By default IE8 forces intranet websites into compatibility mode. I tried changing the meta header to IE8, but it doesn't acknowledge the meta header and just uses the browser setting. Does anyone know how to disable this?


Source: (StackOverflow)

Detect IE version (prior to v9) in Javascript

I want to bounce users of our web site to an error page if they're using a version of Internet Explorer prior to v9. It's just not worth our time and money to support IE pre-v9. Users of all other non-IE browsers are fine and shouldn't be bounced. Here's the proposed code:

if(navigator.appName.indexOf("Internet Explorer")!=-1){     //yeah, he's using IE
    var badBrowser=(
        navigator.appVersion.indexOf("MSIE 9")==-1 &&   //v9 is ok
        navigator.appVersion.indexOf("MSIE 1")==-1  //v10, 11, 12, etc. is fine too
    );

    if(badBrowser){
        // navigate to error page
    }
}

Will this code do the trick?

To head off a few comments that will probably be coming my way:

[1] Yes, I know that users can forge their useragent string. I'm not concerned.

[2] Yes, I know that programming pros prefer sniffing out feature-support instead of browser-type but I don't feel this approach makes sense in this case. I already know that all (relevant) non-IE browsers support the features that I need and that all pre-v9 IE browsers don't. Checking feature by feature throughout the site would be a waste.

[3] Yes, I know that someone trying to access the site using IE v1 (or >= 20) wouldn't get 'badBrowser' set to true and the warning page wouldn't be displayed properly. That's a risk we're willing to take.

[4] Yes, I know that Microsoft has "conditional comments" that can be used for precise browser version detection. IE no longer supports conditional comments as of IE 10, rendering this approach absolutely useless.

Any other obvious issues to be aware of? Thanks.


Source: (StackOverflow)

How can I prevent the backspace key from navigating back?

On IE I can do this with the (terribly non-standard, but working) jQuery

if ($.browser.msie)
    $(document).keydown(function(e) { if (e.keyCode == 8) window.event.keyCode = 0;});

But is it possible to do in a way which works on Firefox, or in a cross-browser way for a bonus?

For the record:

$(document).keydown(function(e) { if (e.keyCode == 8) e.stopPropagation(); });

does nothing.

$(document).keydown(function(e) { if (e.keyCode == 8) e.preventDefault(); });

solves the problem, but renders the backspace key unusable on the page, which is even worse than the original behaviour.

EDIT: The reason I do this is that I'm not creating a simple web page but a large application. It is incredibly annoying to lose 10 minutes of work just because you pressed backspace in the wrong place. The ratio of preventing mistakes vs. annoying users should be way above 1000/1 by preventing the backspace key from navigating back.

EDIT2: I'm not trying to prevent history navigation, just accidents.

EDIT3: @brentonstrines comment (moved here since the question is so popular): This is a long-term 'fix', but you could throw your support behind the Chromium bug to change this behavior in webkit


Source: (StackOverflow)

Tools to selectively copy HTML+CSS+JS from existing sites

Like most web developers, I occasionally like to look at the source of websites to see how their markup is built. Tools like Firebug and Chrome Developer Tools make it easy to inspect the code, but if I want to copy an isolated section and play around with it locally, it would be a pain to copy all the individual elements and their associated css. And probably just as much work to save the entire source and cut out the unrelated code.

It would be great if I could right-click a node in Firebug and have a "Save HTML+CSS for this node" option. Does such a tool exist? Is it possible to extend Firebug or Chrome Developer Tools to add this feature?


Source: (StackOverflow)

Force IE compatibility mode off using tags

I am doing work for a client who forces compatibility mode on all intranet sites. I was wondering if there is a tag I can put into my HTML that forces compatibility mode off.


Source: (StackOverflow)

Using tags to turn off caching in all browsers?

I read that when you don't have access to the web server's headers you can turn off the cache using:

<meta http-equiv="Cache-Control" content="no-store" />

But I also read that this doesn't work in some versions of IE. Are there any set of <meta> tags that will turn off cache in all browsers?


Source: (StackOverflow)

'innerText' works in IE, but not in Firefox

I have some JavaScript code that works in IE containing the following:

myElement.innerText = "foo";

However, it seems that the 'innerText' property does not work in Firefox. Is there some Firefox equivalent? Or is there a more generic, cross browser property that can be used?


Source: (StackOverflow)