I’m currently working on a small script that displays a div above all the other content on the page in reference to a selected button. It’s working perfectly in firefox but not in IE at all. Any ideas ?
[CODE]
openWindow = false;
iconWindow = null;
function showIconWindow(iconType, element) {
element.style.backgroundColor = “#FF0000”;
//create window above and to the left of the icon
posX = element.offsetLeft;
posY = element.offsetTop;
//if no other windows are open
if (openWindow == false) {
iconWindow = document.createElement(‘div’);
iconWindow.style.width = “250px”;
iconWindow.style.height = “30px”;
iconWindow.style.backgroundColor = “#FFFFFF”;
iconWindow.style.position = “absolute”;
iconWindow.style.float = “none”;
iconWindow.style.left = (posX – 238)+”px”;
iconWindow.style.top = (posY – 30)+”px”;
iconWindow.style.display=”block”;
document.body.appendChild(iconWindow);
openWindow = true;
}
}
<i>
</i>openWindow = false;
iconWindow = null;
function showIconWindow(iconType, element) {
element.style.backgroundColor = "#FF0000";
<i> </i>//create window above and to the left of the icon
<i> </i>var posX = element.offsetLeft;
<i> </i>var posY = element.offsetTop;
<i> </i>//if no other windows are open
<i> </i>if (!openWindow) {
<i> </i> iconWindow = document.createElement('div');
<i> </i> iconWindow.style.width = "250px";
<i> </i> iconWindow.style.height = "30px";
<i> </i> iconWindow.style.backgroundColor = "#FFFFFF";
<i> </i> iconWindow.style.position = "absolute";
<i> </i> iconWindow.style.left = (posX - 238)+"px";
<i> </i> iconWindow.style.top = (posY - 30)+"px";
<i> </i> iconWindow.style.display="block";
<i> </i> document.getElementsByTagName("body")[0].appendChild(iconWindow);
<i> </i> openWindow = true;
<i> </i>}
}
Maybe?<i>
</i>function showIconWindow(iconType, element) {
alert("Function called");
element.style.backgroundColor = "#FF0000";
<i> </i>//create window above and to the left of the icon
<i> </i>alert("backgroundColor okay");
<i> </i>var posX = element.offsetLeft;
<i> </i>var posY = element.offsetTop;
<i> </i>alert("positionX and Yn"+posX+"n"+posY);
<i> </i>//if no other windows are open
<i> </i>if (!openWindow) {alert("openWindow = false");
<i> </i> iconWindow = document.createElement('div');
<i> </i> alert("Element created");
<i> </i> iconWindow.style.width = "250px";
<i> </i> iconWindow.style.height = "30px";
<i> </i> alert("Style and width okay");
<i> </i> iconWindow.style.backgroundColor = "#FFFFFF";
<i> </i> alert("Background okay");
<i> </i> iconWindow.style.position = "absolute";
<i> </i> alert("!!position = true");
<i> </i> iconWindow.style.left = (posX - 238)+"px";
<i> </i> alert("Style.left okay");
<i> </i> iconWindow.style.top = (posY - 30)+"px";
<i> </i> alert("Style.top okay");
<i> </i> iconWindow.style.display="block";
<i> </i> alert("Display block");
document.getElementsByTagName("body")[0].appendChild(iconWindow);
alert("Element appended");
openWindow = true;
}
}
<i>
</i> iconWindow = document.createElement('div');
iconWindow.style.width = "250px";
iconWindow.style.height = "30px";
iconWindow.style.backgroundColor = "#FFFFFF";
iconWindow.style.position = "absolute";
iconWindow.style.float = "none";
iconWindow.style.left = (posX - 238)+"px";
iconWindow.style.top = (posY - 30)+"px";
iconWindow.style.display="block";
[COLOR="Red"]iconWindow.appendChild(document.createTextNode("test"))[/COLOR]
document.body.appendChild(iconWindow);
add a text node to the div:
[/QUOTE]
<i>
</i> iconWindow = document.createElement('div');
iconWindow.style.width = "250px";
iconWindow.style.height = "30px";
iconWindow.style.backgroundColor = "#FFFFFF";
iconWindow.style.position = "absolute";
iconWindow.style.float = "none";
iconWindow.style.left = (posX - 238)+"px";
iconWindow.style.top = (posY - 30)+"px";
iconWindow.style.display="block";
[COLOR="Red"]iconWindow.appendChild(document.createTextNode("test"))[/COLOR]
document.body.appendChild(iconWindow);
[CODE]<div style="width:100%;height:100%;z-index:-1;background:black;display:none;position:absolute;top:0px;left:0px;[B]filter:alpha(opacity=50);-moz-opacity:.50;opacity:.50;[/B]"></div>
<div id="box_with_pictures">pictures and stuff</div>[/CODE]
[CODE]document.body.onload=document.body.appendChild(element);
[/CODE]
[CODE]document.body.onload=setTimeout("document.body.appendChild(element)",1000);
[/CODE]
[CODE]try{
document.body.onload=setTimeout("document.body.appendChild(element)",1000);
} catch (err) {} [/CODE]
[CODE]var iconWindow = document.createElement('div');
iconWindow.style.width = "250px";
iconWindow.style.height = "30px";
iconWindow.style.backgroundColor = "#FFFFFF";
iconWindow.style.position = "absolute";
iconWindow.style.float = "none";
iconWindow.style.left = (posX - 238)+"px";
iconWindow.style.top = (posY - 30)+"px";
iconWindow.style.display="block";
iconWindow.appendChild(document.createTextNode("test"))
try{
document.body.onload=setTimeout("document.body.appendChild(iconWindow);",1000);
} catch (err) {}[/CODE]
[CODE] var Count = -1;
function add_tpl()
{
Count++;
var new_tpl_min_comm = document.createElement('input');
new_tpl_min_comm.type = 'text';
new_tpl_min_comm.name = 'min_comm['+Count+']';
new_tpl_min_comm.size = '7';
var new_tpl_max_comm = document.createElement('input');
new_tpl_max_comm.type = 'hidden';
new_tpl_max_comm.name = 'max_comm['+Count+']';
new_tpl_max_comm.size = '7';
var new_tpl_value = document.createElement('input');
new_tpl_value.type = 'text';
new_tpl_value.name = 'tpl_value['+Count+']';
new_tpl_value.size = '7';
var new_tpl_type_select = document.createElement('select');
new_tpl_type_select.id = 'tpl_select['+Count+']';
new_tpl_type_select.name = 'tpl_select['+Count+']';
var new_tpl_type_option = document.createElement('option');
new_tpl_type_option.value = '0';
new_tpl_type_option.text = '<? echo iconv("utf-8","windows-1251","я┌п╦п©")?>';
var new_tpl_type_option1 = document.createElement('option');
new_tpl_type_option1.value = '1';
new_tpl_type_option1.text = '%';
var new_tpl_type_option2 = document.createElement('option');
new_tpl_type_option2.value = '2';
new_tpl_type_option2.text = '<? echo iconv("utf-8","windows-1251","я─я┐п╠п╩п╦")?>';
var new_tr = document.createElement('tr');
new_tr.id = 'new_tr['+Count+']';
var new_td2 = document.createElement('td');
new_td2.id = 'new_td2['+Count+']';
var new_td3 = document.createElement('td');
new_td3.id = 'new_td3['+Count+']';
var new_td4 = document.createElement('td');
new_td4.id = 'new_td4['+Count+']';
var new_td5 = document.createElement('td');
new_td5.id = 'new_td5['+Count+']';
var new_br = document.createElement('br');
var new_br1 = document.createElement('br');
var new_br2 = document.createElement('br');
var new_br3 = document.createElement('br');
var new_br4 = document.createElement('br');
var new_br5 = document.createElement('br');
var textNodeMin = document.createTextNode('<? echo iconv("utf-8","windows-1251","п·я┌:")?>');
var textNodeMax = document.createTextNode('<? echo iconv("utf-8","windows-1251","")?>');
var textNodeValue = document.createTextNode('<? echo iconv("utf-8","windows-1251","я─я┐п╠. п*п╬п╪п╦я│я│п╦я▐")?>');
var textNodeRub = document.createTextNode('<? echo iconv("utf-8","windows-1251","")?>');
document.getElementById('fs').appendChild(new_tr);
document.getElementById('new_tr['+Count+']').appendChild(new_td2);
document.getElementById('new_tr['+Count+']').appendChild(new_td3);
document.getElementById('new_tr['+Count+']').appendChild(new_td4);
document.getElementById('new_tr['+Count+']').appendChild(new_td5);
document.getElementById('new_td2['+Count+']').appendChild(textNodeMin);
document.getElementById('new_td2['+Count+']').appendChild(new_tpl_min_comm);
document.getElementById('new_td3['+Count+']').appendChild(textNodeMax);
document.getElementById('new_td3['+Count+']').appendChild(new_tpl_max_comm);
document.getElementById('new_td4['+Count+']').appendChild(textNodeValue);
document.getElementById('new_td4['+Count+']').appendChild(new_tpl_value);
document.getElementById('new_td5['+Count+']').appendChild(new_tpl_type_select);
document.getElementById('tpl_select['+Count+']').appendChild(new_tpl_type_option);
document.getElementById('tpl_select['+Count+']').appendChild(new_tpl_type_option1);
document.getElementById('tpl_select['+Count+']').appendChild(new_tpl_type_option2);
}
[/CODE]
great solution man) , can u help me without my problem?- there is no createElement in IEYes there is:
[/QUOTE]
document.getElementById('new_tr['+Count+']').appendChild(new_td2);
should probably be:new_tr[Count].appendChild(new_td2);
0.1.9 — BETA 5.15