Javascript-форум (https://javascript.ru/forum/)
-   Javascript под браузер (https://javascript.ru/forum/css-html/)
-   -   createElement под IE6 не работает, в чем проблема? (https://javascript.ru/forum/css-html/19073-createelement-pod-ie6-ne-rabotaet-v-chem-problema.html)

prototype 25.07.2011 14:58

createElement под IE6 не работает, в чем проблема?
 
Во всех браузерах работает, в IE 6 не создает табличку...
Подскажите в чем проблема? ошибок не выдает

var ie = window.navigator.appName=='Microsoft Internet Explorer' ? true : false;

		var el=[];
		el[0]= document.createElement('div');
		el[0].setAttribute('id', 'tooltip_panel');
		el[0].setAttribute('style', 'position: absolute; z-index: 30; visibility:hidden; display:none;');
		document.body.appendChild(el[0]);
		
		el[1]= document.createElement('table');
		el[1].setAttribute('border', '0');
		el[1].setAttribute('cellspacing', '0');
		el[1].setAttribute('cellpadding', '0');
		el[0].appendChild(el[1]);
		
		el[2]= document.createElement('tr');
		el[1].appendChild(el[2]);
		
		
		el[14]= document.createElement('td');
		el[2].appendChild(el[14]);
		
		
		el[3]= document.createElement('div');
		if(args['img']) {
			if(ie && args['bg_img_1'].toLowerCase().indexOf('.png')!= -1) {
				el[3].setAttribute('style', 'background:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+args['bg_img_1']+'",sizingMethod="scale"); width:'+args['width']+'px; height:'+args['height']+'px;');
			}
			else {
				el[3].setAttribute('style', 'background-image:url('+args['bg_img_1']+'); width:'+args['width']+'px; height:'+args['height']+'px;');
			}
		}
		else {
			el[3].setAttribute('style', 'border-top:'+args['border']+'; border-left:'+args['border']+'; background-color:'+args['bg_color']+'; width:'+args['width']+'px; height:'+args['height']+'px;');
		}
		el[14].appendChild(el[3]);
		
		
		el[15]= document.createElement('td');
		el[2].appendChild(el[15]);
		
		
		el[4]= document.createElement('div');
		if(args['img']) {
			if(ie && args['bg_img_2'].toLowerCase().indexOf('.png')!= -1) {
				el[4].setAttribute('style', 'background:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+args['bg_img_2']+'",sizingMethod="scale"); height:'+args['height']+'px;');
			}
			else {
				el[4].setAttribute('style', 'background-image:url('+args['bg_img_2']+'); height:'+args['height']+'px;');
			}
		}
		else {
			el[4].setAttribute('style', 'border-top:'+args['border']+'; background-color:'+args['bg_color']+'; height:'+args['height']+'px;');
		}
		el[15].appendChild(el[4]);
		
		
		el[16]= document.createElement('td');
		el[2].appendChild(el[16]);
		
		
		el[5]= document.createElement('div');
		if(args['img']) {
			if(ie && args['bg_img_3'].toLowerCase().indexOf('.png')!= -1) {
				el[5].setAttribute('style', 'background:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+args['bg_img_3']+'",sizingMethod="scale"); width:'+args['width']+'px; height:'+args['height']+'px;');
			}
			else {
				el[5].setAttribute('style', 'background-image:url('+args['bg_img_3']+'); width:'+args['width']+'px; height:'+args['height']+'px;');
			}
		}
		else {
			el[5].setAttribute('style', 'border-top:'+args['border']+'; border-right:'+args['border']+'; background-color:'+args['bg_color']+'; width:'+args['width']+'px; height:'+args['height']+'px;');
		}
		el[16].appendChild(el[5]);
		
		
		el[6]= document.createElement('tr');
		el[1].appendChild(el[6]);
		
		
		el[7]= document.createElement('td');
		if(args['img']) {
			if(ie && args['bg_img_4'].toLowerCase().indexOf('.png')!= -1) {
				el[7].setAttribute('style', 'background:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+args['bg_img_4']+'",sizingMethod="scale"); width:'+args['width']+'px;');
			}
			else {
				el[7].setAttribute('style', 'background-image:url('+args['bg_img_4']+'); width:'+args['width']+'px;');
			}
		}
		else {
			el[7].setAttribute('style', 'border-left:'+args['border']+'; background-color:'+args['bg_color']+'; width:'+args['width']+'px;');
		}
		el[6].appendChild(el[7]);
		
		
		el[17]= document.createElement('td');
		el[6].appendChild(el[17]);
		
		
		el[8]= document.createElement('div');
		el[8].setAttribute('id', 'td_tooltip_txt');
		el[8].setAttribute('style', 'font-family:Tahoma,Verdana,Arial,Times New Roman,Helvetica,sans-serif; font-size:'+args['font']+'px; background-color:'+args['bg_color']+';white-space:nowrap;');
		el[17].appendChild(el[8]);
		
		
		el[9]= document.createElement('td');
		if(args['img']) {
			if(ie && args['bg_img_5'].toLowerCase().indexOf('.png')!= -1) {
				el[9].setAttribute('style', 'background:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+args['bg_img_5']+'",sizingMethod="scale"); width:'+args['width']+'px;');
			}
			else {
				el[9].setAttribute('style', 'background-image:url('+args['bg_img_5']+'); width:'+args['width']+'px;');
			}
		}
		else {
			el[9].setAttribute('style', 'border-right:'+args['border']+'; background-color:'+args['bg_color']+'; width:'+args['width']+'px;');
		}
		el[6].appendChild(el[9]);
		
		
		el[10]= document.createElement('tr');
		el[1].appendChild(el[10]);
		
		
		el[18]= document.createElement('td');
		el[10].appendChild(el[18]);
		
		
		el[11]= document.createElement('div');
		if(args['img']) {
			if(ie && args['bg_img_6'].toLowerCase().indexOf('.png')!= -1) {
				el[11].setAttribute('style', 'background:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+args['bg_img_6']+'",sizingMethod="scale"); width:'+args['width']+'px; height:'+args['height']+'px;');
			}
			else {
				el[11].setAttribute('style', 'background-image:url('+args['bg_img_6']+'); width:'+args['width']+'px; height:'+args['height']+'px;');
			}
		}
		else {
			el[11].setAttribute('style', 'border-bottom:'+args['border']+'; border-left:'+args['border']+'; background-color:'+args['bg_color']+'; width:'+args['width']+'px; height:'+args['height']+'px;');
		}
		el[18].appendChild(el[11]);
		
		
		el[19]= document.createElement('td');
		el[10].appendChild(el[19]);
		
		
		el[12]= document.createElement('div');
		if(args['img']) {
			if(ie && args['bg_img_7'].toLowerCase().indexOf('.png')!= -1) {
				el[12].setAttribute('style', 'background:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+args['bg_img_7']+'",sizingMethod="scale"); height:'+args['height']+'px;');
			}
			else {
				el[12].setAttribute('style', 'background-image:url('+args['bg_img_7']+'); height:'+args['height']+'px;');
			}
		}
		else {
			el[12].setAttribute('style', 'border-bottom:'+args['border']+'; background-color:'+args['bg_color']+'; height:'+args['height']+'px;');
		}
		el[19].appendChild(el[12]);
		
		
		el[20]= document.createElement('td');
		el[10].appendChild(el[20]);
		
		
		el[13]= document.createElement('div');
		if(args['img']) {
			if(ie && args['bg_img_8'].toLowerCase().indexOf('.png')!= -1) {
				el[13].setAttribute('style', 'background:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+args['bg_img_8']+'",sizingMethod="scale"); width:'+args['width']+'px; height:'+args['height']+'px;');
			}
			else {
				el[13].setAttribute('style', 'background-image:url('+args['bg_img_8']+'); width:'+args['width']+'px; height:'+args['height']+'px;');
			}
		}
		else {
			el[13].setAttribute('style', 'border-bottom:'+args['border']+'; border-right:'+args['border']+'; background-color:'+args['bg_color']+'; width:'+args['width']+'px; height:'+args['height']+'px;');
		}
		el[20].appendChild(el[13]);


Создает вот такой код:
причем для каждого браузера свой

<div style="position: absolute; z-index: 30; visibility: visible; display: block; opacity: 1; left: 592px; top: 360px;" id="tooltip_panel">
 <table border="0" cellpadding="0" cellspacing="0">

  <tr>
   <td><div style="background-image: url(&quot;imgtool/tooltip-1.png&quot;); width: 19px; height: 15px;"></div></td>
   <td><div style="background-image: url(&quot;imgtool/tooltip-2.png&quot;); height: 15px;"></div></td>
   <td><div style="background-image: url(&quot;imgtool/tooltip-3.png&quot;); width: 19px; height: 15px;"></div></td>
  </tr>

  <tr>
   <td style="background-image: url(&quot;imgtool/tooltip-4.png&quot;); width: 19px;"></td>
   <td><div style="font-family: Tahoma,Verdana,Arial,Times New Roman,Helvetica,sans-serif; font-size: 12px; background-color: rgb(255, 255, 255); white-space: nowrap;" id="td_tooltip_txt"></div></td>
   <td style="background-image: url(&quot;imgtool/tooltip-5.png&quot;); width: 19px;"></td>
  </tr>

  <tr>
   <td><div style="background-image: url(&quot;imgtool/tooltip-6.png&quot;); width: 19px; height: 15px;"></div></td>
   <td><div style="background-image: url(&quot;imgtool/tooltip-7.png&quot;); height: 15px;"></div></td>
   <td><div style="background-image: url(&quot;imgtool/tooltip-8.png&quot;); width: 19px; height: 15px;"></div></td>
  </tr>

 </table>
</div>

Octane 26.07.2011 04:52

http://webew.ru/articles/598.webew

Цитата:

Сообщение от prototype
var ie = window.navigator.appName=='Microsoft Internet Explorer' ? true : false;

:D зачем здесь тернарный оператор?

prototype 27.07.2011 23:14

Цитата:

Сообщение от Octane
Сообщение от prototype
var ie = window.navigator.appName=='Microsoft Internet Explorer' ? true : false;
зачем здесь тернарный оператор?

потому что document.all не всегда правильное решение, смотрите манулы
например оперу может принять за IE

Octane 27.07.2011 23:18

var str = "abcdef";
var test = str == "abcdef";
alert(test);


Часовой пояс GMT +3, время: 23:54.