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;');
$('container').insert({
before:contfaltandias
});
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
use var contfaltandias = document.createElement('div');
https://developer.mozilla.org/en/DOM/document.createElement
$('container').insert({
before:contfaltandias
});
Leandro Cusack 2012-04-04 17:58
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
console.log(typeof $);
just before $('container').insert({
nathanjosiah 2012-04-04 18:19
alert(typeof $);
nathanjosiah 2012-04-04 18:23
alert(typeof $('container'));
and alert(typeof $('container').insert);
nathanjosiah 2012-04-04 18:32
As far as I know, new elements are created using document.createElement('type'). You should try to replace
var contfaltandias = new Element('div');
with
var contfaltandias = document.createElement('div');
Then, it should work.