как .innerHTML = content в блоке контент заставить работать java script?

Статус
В этой теме нельзя размещать новые ответы.

dandandan

Мой дом здесь!
Регистрация
7 Авг 2008
Сообщения
1.036
Реакции
292
С помощью ява скрипта делаю окно на div. Требуется, чтобы функция close_all() заработала.
Код:
function showError(text, ipadress){    
var content='<input name="sdlkfj" type="button" value="Закрыть" onclick="close_all();" />';

var divIdName = 'previewDiv';      
var newdiv = document.getElementById(divIdName);     
if(!newdiv){         
    newdiv = document.createElement('div');      
    newdiv.setAttribute('id', divIdName);      
    newdiv.setAttribute('class','block');      
    //Hide on click      
   /* newdiv.onclick = function(){ this.style.display = 'none';};      */
  
  var newButtonClose= document.createElement('button'); 
  newButtonSend.setAttribute('type', 'button');
  newButtonClose.onclick = function(){ this.style.display = 'none';};
  
  var newButtonSend= document.createElement('button'); 
  newButtonSend.setAttribute('type', 'submit');
  newButtonSend.onclick = function(){ send_data(); this.style.display = 'none';};   
  document.body.appendChild(newdiv);     
  } 
  //Overwrite new content      
newdiv.innerHTML = content; 
newdiv.style.display ='block';
newdiv.style.border ='1';
newdiv.style.background ='#C0DCC0';
newdiv.style.position ='fixed';
newdiv.style.overflow ='auto';
newdiv.style.width ='400px';
newdiv.style.height ='200px';
newdiv.style.left ='50%';
newdiv.style.top ='50%';
newdiv.style.marginLeft ='-200px';
newdiv.style.marginTop ='-100px';
}
 
С помощью ява скрипта делаю окно на div. Требуется, чтобы функция close_all() заработала.
Код:
function showError(text, ipadress){    
var content='<input name="sdlkfj" type="button" value="Закрыть" onclick="close_all();" />';
var divIdName = 'previewDiv';      
var newdiv = document.getElementById(divIdName);     
if(!newdiv){         
    newdiv = document.createElement('div');      
    newdiv.setAttribute('id', divIdName);      
    newdiv.setAttribute('class','block');      
    //Hide on click      
  var newButtonClose= document.createElement('button'); 
  newButtonSend.setAttribute('type', 'button');
  newButtonClose.onclick = function(){ this.style.display = 'none';};
  var newButtonSend= document.createElement('button'); 
  newButtonSend.setAttribute('type', 'submit');
  newButtonSend.onclick = function(){ send_data(); this.style.display = 'none';};   
  document.body.appendChild(newdiv);     
  } 
  //Overwrite new content      
newdiv.innerHTML = content; 
newdiv.style.display ='block';
newdiv.style.border ='1';
newdiv.style.background ='#C0DCC0';
newdiv.style.position ='fixed';
newdiv.style.overflow ='auto';
newdiv.style.width ='400px';
newdiv.style.height ='200px';
newdiv.style.left ='50%';
newdiv.style.top ='50%';
newdiv.style.marginLeft ='-200px';
newdiv.style.marginTop ='-100px';
}
Что то не вижу самой функции close_all,
приведите ее листинг. Что она должна делать?
Если просто скрывать этот div то она будет выглядеть следующим образом
function close_all()
{
document.getElementById('Здесь_ID_diva').style.display = 'none';
}
 
В том то и дело, что эту кнопочку с висящей на ней функцией нужно программно внедрить.
 
Статус
В этой теме нельзя размещать новые ответы.
Назад
Сверху