Object doesn´t support this action

Go To StackoverFlow.com


I have the following code which is throwing me that error on IE 7 :

if (navigator.appName == 'Microsoft Internet Explorer') {
            var ua = navigator.userAgent;
            var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
            if (re.exec(ua) != null){
              rv = parseFloat( RegExp.$1 );
              if (rv == 7){
                  var contfaltandias = new Element('div');
                    contfaltandias.setAttribute('id', 'contfaltandias');
                    contfaltandias.setAttribute('style', 'display:none; width:100%; height:100%; z-index:1000; background:#003377; position: absolute; top:0;');
                    new Effect.Parallel([
                                      new Effect.Appear('contfaltandias', { sync: true, duration: 2.0 }), 
                                      new Effect.Highlight('contfaltandias', { sync:true, startcolor: '#ff6000', endcolor: '#ffffff' }) 
                                 ], { 
                                     duration: 5.0,
                                     delay: 0

I have found that the line that is causing problems is this:

var contfaltandias = new Element('div');

But why? Any help would be appreciated

//it is for display a message to move on to the newest version, I am not a Bad programmer like someone says there

2012-04-04 17:52
by Leandro Cusack
I wasn't aware people still wrote code that did browser sniffing. And after all the talk about how freaking evil it is, too? Bad programmer! No cookie for you - cHao 2012-04-04 17:55
Because I have to show a message for people that is using IE 7 to move on to the next version, 8,9 or mozilla - Leandro Cusack 2012-04-04 18:03
Psh. Don't show a message for them. Don't do anything for them. They're the slackers that have already had 5+ years worth of opportunities and never bothered; they're not gonna do it now just cause you added some crap to your page. If the site looks spiffy for them, cool. If it doesn't, oh well. If you did the "progressive enhancement" thing, all's good anyway. And if you didn't...well...Bad programmer! No cookie - cHao 2012-04-04 18:48


use var contfaltandias = document.createElement('div'); https://developer.mozilla.org/en/DOM/document.createElement

2012-04-04 17:53
by nathanjosiah
Thank you. Now it is giving me error with this method: $('container').insert({ before:contfaltandias });Leandro Cusack 2012-04-04 17:58
@Leandro which method - nathanjosiah 2012-04-04 17:59
Sorry, I have edited the comment above with the method. I hate prototype, I do not know why it is not working - Leandro Cusack 2012-04-04 18:01
I tested over and over using the modified code but the only error I could get was when container doesn't exist, are you sure there is an element with the id of container at the time this code is run - nathanjosiah 2012-04-04 18:13
The error is only present at IE7. The debbuger shows: "Object doesn't support this property or method" at the line where "insert()" method begins. I do not know what could ir cause the issue. Maybe the scripts order - Leandro Cusack 2012-04-04 18:17
it could be the script order, what does it output if you console.log(typeof $); just before $('container').insert({nathanjosiah 2012-04-04 18:19
It output "'console' is undefined". Weird - Leandro Cusack 2012-04-04 18:22
change it to alert(typeof $);nathanjosiah 2012-04-04 18:23
it alerted "function", I think that it is ok, isn't it - Leandro Cusack 2012-04-04 18:26
how about alert(typeof $('container')); and alert(typeof $('container').insert);nathanjosiah 2012-04-04 18:32
alert(typeof $('container')); throws: Object, but alert(typeof $('container').insert); throws: undefine - Leandro Cusack 2012-04-04 18:36
you should open a new question with that problem - nathanjosiah 2012-04-04 18:43


As far as I know, new elements are created using document.createElement('type'). You should try to replace

var contfaltandias = new Element('div');


var contfaltandias = document.createElement('div');

Then, it should work.

2012-04-04 17:56
by Dominik M.