jquery.selectBoxIt.js icon indicating copy to clipboard operation
jquery.selectBoxIt.js copied to clipboard

Windows 7 ie10 issue

Open adamjw3 opened this issue 12 years ago • 15 comments

There seems to be an issue with pages using selectboxit in ie10 on windows 7. its fine in windows 8. any ideas?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/966972-windows-7-ie10-issue?utm_campaign=plugin&utm_content=tracker%2F23157&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F23157&utm_medium=issues&utm_source=github).

adamjw3 avatar May 03 '13 16:05 adamjw3

What are the issues you are seeing on IE10 on Windows 7?

gfranko avatar May 04 '13 22:05 gfranko

it stops the page from loading. i'm using the basic call

$("select").selectBoxIt();

adamjw3 avatar May 07 '13 11:05 adamjw3

hi a bit more info.

i'm using the latest version and downloaded the full repository (v3.4.0 ). if you try to view the demo in ie 10 on windows 7 you get a black browser. i've used version 2.9 on projects in the past and these work across all browsers including ie10

adamjw3 avatar May 07 '13 14:05 adamjw3

I just tried the demo inside of Windows 7 IE 10 and it seems to work fine. Do you see any JavaScript errors being thrown?

gfranko avatar May 09 '13 02:05 gfranko

I am closing this right now because I don't see an issue on IE10, but I will reopen it if you can show me that there is.

gfranko avatar May 10 '13 12:05 gfranko

@gfranko I can confirm that selectBoxIt crashes IE10, but not directly. It somehow spoils the document.getElementsByName() method and as soon as this method is called - browser crashes. The easier way to reproduce is to initialize selectBoxIt and then call from the console document.getElementsByName('qwe').

This issues is not reproducible in emulation mode of IE11. But easily reproducible on VM running IE10 on Windows 7. We were not able to reproduce that in IE9 or IE8, but we haven't tested them a lot.

aboritskiy avatar May 09 '14 09:05 aboritskiy

Confirmed. We just had a client that reported a crash in IE10 when submitting a form, and we quickly tracked the crash down to selectBoxIt.

Running document.getElementsByName('qwe'), as you suggested @aboritskiy, reproduces the crash.

Let me know if you find any workarounds.

heintore avatar May 09 '14 10:05 heintore

I can confirm the same. I'm running IE10.0.15 on Win8. After initializing selectBoxIt, any call to getElementsByName will cause to IE to crash. It'll close with a "Internet Explorer has stopped working" popup.

All other browsers are fine.

homecoded avatar May 09 '14 15:05 homecoded

I'm looking into this right now. Not fun to debug lol.

gfranko avatar May 09 '14 15:05 gfranko

I'm not sure why this is happening, but if you add a name attribute to each of your select boxes, the problem goes away. Will continue to look into this.

gfranko avatar May 09 '14 17:05 gfranko

Confirmed, thanks a lot! This fixes the crash for me.

heintore avatar May 09 '14 18:05 heintore

@gfranko, consider adding such code to seletBoxIT

/**
 * Generates names for select boxes in case they are empty. Attempts to use id as a name if id is set.
 *
 * @param {jQuery} $selects
 */
var generateSelectBoxNames = function ($selects) {
    $selects.each(function (iIndex) {
        var $this = $(this);
        var sName = $this.attr('name');
        var sId = $this.attr('id');
        if (typeof sName !== 'undefined' && sName.length > 0) {
            /* nothing to do here */
            return;
        }

        if (typeof sId !== 'undefined' && sId.length > 0) {
            /* use id as name */
            $this.attr('name', sId);
            return;
        }

        $this.attr('name', 'select-box-' + iIndex);
    });
};

This code fixed the issue for me.

aboritskiy avatar Jun 17 '14 09:06 aboritskiy

@aboritskiy Interesting, thanks!

gfranko avatar Jun 17 '14 18:06 gfranko

Hi,

if you are talking about this fix:

/**

  • Generates names for select boxes in case they are empty. Attempts to use id as a name if id is set. *

  • @param {jQuery} $selects / var generateSelectBoxNames = function ($selects) { $selects.each(function (iIndex) { var $this = $(this); var sName = $this.attr('name'); var sId = $this.attr('id'); if (typeof sName !== 'undefined' && sName.length > 0) { / nothing to do here */ return; }

    if (typeof sId !== 'undefined' && sId.length > 0) {
        /* use id as name */
        $this.attr('name', sId);
        return;
    }
    
    $this.attr('name', 'select-box-' + iIndex);
    

    }); }; then just before or after calling select-box-it, call this method passing the jQuery collection with your selects as an argument. Smth like this:

var $selects = $('select'); $selects.selectBoxIt(); generateSelectBoxNames($selects); This fixes the problem because IE has some troubles with select fields without name attribute. When your select field has name - you are safe.

Best regards, Anton Boritskiy

Fri, 14 Nov 2014 11:48:05 -0800 от manuferre [email protected]:

Hi, @gfranko , @aboritskiy , I downloaded the lastest version of the selectBoxIt.js but the bug is still there, How can I implement the fix? editing directly the code?, in what lines? Thanks a lot in advance — Reply to this email directly or view it on GitHub .

aboritskiy avatar Nov 18 '14 19:11 aboritskiy

Thanks @aboritskiy & @gfranko

manuferre avatar Nov 18 '14 20:11 manuferre