Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/09/2011, 09:49
Avatar de JuJoGuAl
JuJoGuAl
 
Fecha de Ingreso: julio-2009
Ubicación: Venezuela
Mensajes: 754
Antigüedad: 14 años, 8 meses
Puntos: 19
Pregunta No se ejecuta JavaScript si pego otro

Hola Buenos dias, disculpen el doble post pero tube problemas para continuar el otro post, les present mi problema. Estoy haciendo un modulo para cargar información del producto, y bueno al principio busque un script en java para subir varias imágenes simultáneamente al sevidor, y el código funcionaba perfecto, después busque un código para colocar un editor WYSIWYG en un tex tarea (editor que probe aparte y funciono) ahora cuando pegue el editor en mi web dejo de funcionar el java para las fotos.
Muestro los cogidos para saber si alguien me puede ayudar:
Script de Imágenes:
Código Javascript:
Ver original
  1. <script type="text/javascript">
  2. var numero = 0;
  3.  
  4. c= function (objeto) {
  5.    return document.createElement(objeto);
  6. }
  7. d = function (identificador) {
  8.    return document.getElementById(identificador);
  9. }
  10. e = function (evento) {
  11.    return (!evento) ? event : evento;
  12. }
  13. f = function (evento) {
  14.    return evento.srcElement ?  evento.srcElement : evento.target;
  15. }
  16.  
  17. addField = function () {
  18.    container = d('files');
  19.    
  20.    span = c('SPAN');
  21.    span.className = 'file';
  22.    span.id = 'file' + (++numero);
  23.  
  24.    field = c('INPUT');  
  25.    field.name = 'pro_foto[]';
  26.    field.type = 'file';
  27.    field.className='cuadro';
  28.    field.size='70';
  29.    
  30.    a = c('A');
  31.    a.name = span.id;
  32.    a.href = '#';
  33.    a.onclick = removeField;
  34.    a.innerHTML = 'Quitar';
  35.  
  36.    span.appendChild(field);
  37.    span.appendChild(a);
  38.    container.appendChild(span);
  39. }
  40. removeField = function (evt) {
  41.    lnk = f(e(evt));
  42.    span = d(lnk.name);
  43.    span.parentNode.removeChild(span);
  44. }
  45. </script>
Y la forma con la que llamo la funcion es asi:
Código HTML:
 <td width="25%" height="25" class="titulo02">Imagenes:<a href="#" class="titulo02" onClick="addField()">Añadir Foto</a></td>
									<td width="80%" height="25" class="titulo02"><div id="files" style="width:400px; font-family:Arial, Helvetica, sans-serif; font-size:14px;"></div></td> 
La funcion de WYSIWYG es:
Código Javascript:
Ver original
  1. var whizzywig_version='Whizzywig 63';
  2. var btn=[];
  3.  btn._w=16; btn._h=16; btn._f=getDir()+"icons.png"; //set to path to toolbar image
  4. var buttonPath,  //path to custom toolbar button images; "textbuttons" means don't use images
  5. buttonExt,  
  6. cssFile,    
  7. imageBrowse,
  8. linkBrowse,  
  9. idTa,      
  10.  
  11. oW, sel, rng, papa, trail, ppw, wn=window, msIE=("Microsoft Internet Explorer"==navigator.appName)
  12. sels='',buts='',vals=[],opts=[],dobut=[],whizzies=[],taOrigSize=[];
  13.  
  14. function makeWhizzyWig(txtArea, controls){ // make a WhizzyWig from the textarea
  15.  idTa=txtArea;
  16.  whizzies[whizzies.length]=idTa;
  17.  if (!document.designMode) {
  18.   if (idTa.nodeName=="TEXTAREA"){tagButs();}
  19.   alert("Whizzywig "+t("editor not available for your browser"));
  20.   return;
  21.  }
  22.  var taContent=o(idTa).defaultValue ? o(idTa).defaultValue : o(idTa).innerHTML ? o(idTa).innerHTML: ''; //anything in the textarea?
  23.  if (!o(idTa).rows < 5){o(idTa).rows='15';}//IE won't use % from style
  24.  taWidth=o(idTa).style.width ? o(idTa).style.width : o(idTa).cols + "ex";  //grab the width and...
  25.  taHeight=o(idTa).style.height ? o(idTa).style.height : o(idTa).rows + "em";  //...height from the textarea
  26.  taOrigSize[idTa] = {w:taWidth,h:taHeight};
  27.  //Create whizzy container
  28.  var wContainer = document.createElement('div');
  29.  wContainer.id = 'CONTAINER'+idTa+'';
  30.  wContainer.style.width = taWidth;
  31.  var taObject = o(idTa);
  32.  o(idTa).parentNode.replaceChild(wContainer, o(idTa));
  33.  o("CONTAINER"+idTa).appendChild(taObject);
  34.  //End whizzy container
  35.  if (o(idTa).nodeName=="TEXTAREA"){
  36.  o(idTa).style.color='#060';
  37.  o(idTa).style.zIndex='2';
  38.  }else{w('<input type="hidden" id="wzhid_'+idTa+'" name="'+idTa+'" />')}
  39.  h(idTa);
  40.  var frm=o(idTa).parentNode;
  41.  while(frm.nodeName != 'FORM'){frm=frm.parentNode}//if not form, keep trying
  42.  addEvt(frm,"submit",syncTextarea);
  43.  w('<style type="text/css">button {vertical-align:middle;padding:0;margin:1px 0} button img{vertical-align:middle;margin:-1px} select{vertical-align:middle;margin:1px}  .wzCtrl {background:ButtonFace; border:1px outset ButtonShadow; padding:5px;} #sourceTa{color:#060;font-family:mono;}</style>');
  44.  var dsels='formatblock fontname fontsize';
  45.  var dbuts=' bold italic underline | left center right justify | number bullet indent outdent | undo redo | color hilite rule | link image table | clean html spellcheck fullscreen ';
  46.  var tbuts=' tstart add_row_above add_row_below delete_row | add_column_before add_column_after delete_column | table_in_cell';
  47.  var t_end=''; //table controls end, if needed
  48.  btns=(dbuts+tbuts).split(' ');
  49.  for (var i=0,pos=0;i<btns.length;i++) {
  50.   if(btns[i] && btns[i]!='|' && btns[i]!='tstart'){btn[btns[i]]=btn._w*pos++}
  51.  }
  52.  controls=controls ? controls.toLowerCase() : "all";
  53.  if(controls == "all"){controls=dsels +' newline '+ buts + dbuts + tbuts}
  54.  else{controls += tbuts}
  55.  w('<div onmouseover="c(\''+idTa+'\')"><div id="CONTROLS'+idTa+'" class="wzCtrl" unselectable="on">');
  56.  gizmos=controls.split(' ');
  57.  for (i=0;i<gizmos.length;i++){
  58.   if (gizmos[i]){ //make buttons and selects for toolbar, in order requested
  59.    if (gizmos[i] == 'tstart') {
  60.     w('<div id="TABLE_CONTROLS'+idTa+'" style="display:none" unselectable="on">');
  61.     t_end='</div>';
  62.    }
  63.    else if(gizmos[i]=='|'){w('&nbsp;<big style="padding-bottom:2em">|</big>&nbsp;')}
  64.    else if(gizmos[i] == 'newline'){w('<br>')}
  65.    else if((dsels+sels).indexOf(gizmos[i]) != -1){makeSelect(gizmos[i])}
  66.    else if((dbuts+buts+tbuts).indexOf(gizmos[i]) != -1){makeButton(gizmos[i])}
  67.   }
  68.  }
  69.  w(t_end)//table controls end
  70.  w('<a href="http://www.unverse.net" style="color:buttonface" title="'+whizzywig_version+'">.</a> ');
  71.  w(fGo('LINK'));
  72.  if (linkBrowse){w('<input type="button" onclick=doWin("'+linkBrowse+'"); value="'+t("Browse")+'"> ')}
  73.  w(t('Link address (URL)')+': <input type="text" id="lf_url'+idTa+'" size="60"><br><input type="button" value="http://" onclick="o(\'lf_url'+idTa+'\').value=\'http://\'+o(\'lf_url'+idTa+'\').value"> <input type="button" value="mailto:" onclick="o(\'lf_url'+idTa+'\').value=\'mailto:\'+o(\'lf_url'+idTa+'\').value"><input type="checkbox" id="lf_new'+idTa+'">'+t("Open link in new window")+fNo(t("OK"),"insertLink()"));//LINK_FORM end
  74.  w(fGo('IMAGE'));
  75.  if(imageBrowse){w('<input type="button" onclick=doWin("'+imageBrowse+'"); value="'+t("Browse")+'"> ')}
  76.  w(t('Image address (URL)')+': <input type="text" id="if_url'+idTa+'" size="50"> <label title='+t("to display if image unavailable")+'><br>'+t("Alternate text")+':<input id="if_alt'+idTa+'" type="text" size="50"></label><br>'+t("Align")+':<select id="if_side'+idTa+'"><option value="none">_&hearts;_ '+t("normal")+'</option><option value="left">&hearts;= &nbsp;'+t("left")+'</option><option value="right">=&hearts; &nbsp;'+t("right")+'</option></select> '+t("Border")+':<input type="text" id="if_border'+idTa+'" size="20" value="0" title="'+t("number or CSS e.g. 3px maroon outset")+'"> '+t("Margin")+':<input type="text" id="if_margin'+idTa+'" size="20" value="0" title="'+t("number or CSS e.g. 5px 1em")+'">'+fNo(t("Insert Image"),"insertImage()"));//IMAGE_FORM end
  77.  w(fGo('TABLE')+t("Rows")+':<input type="text" id="tf_rows'+idTa+'" size="2" value="3"> <select id="tf_head'+idTa+'"><option value="0">'+t("No header row")+'</option><option value="1">'+t("Include header row")+'</option></select> '+t("Columns")+':<input type="text" id="tf_cols'+idTa+'" size="2" value="3"> '+t("Border width")+':<input type="text" id="tf_border'+idTa+'" size="2" value="1"> '+fNo(t("Insert Table"),"makeTable()"));//TABLE_FORM end
  78.  w(fGo('COLOR')+'<input type="hidden" id="cf_cmd'+idTa+'"><div style="background:#000;padding:1px;height:22px;width:125px;float:left"><div id="cPrvw'+idTa+'" style="background-color:red; height:100%; width:100%"></div></div> <input type=text id="cf_color'+idTa+'" value="red" size=17 onpaste=vC(value) onblur=vC(value)> <input type="button" onmouseover=vC() onclick=sC() value="'+t("OK")+'">  <input type="button" onclick="hideDialogs();" value="'+t("Cancel")+'"><br> '+t("click below or enter a")+' <a href="http://www.unverse.net/colortable.htm" target="_blank">'+t("color name")+'</a><br clear=all> <table border=0 cellspacing=1 cellpadding=0 width=480 bgcolor="#000000">'+"\n");
  79.  var wC=new Array("00","33","66","99","CC","FF")  //color table
  80.  for (i=0; i<wC.length; i++){
  81.   w("<tr>");
  82.   for (j=0; j<wC.length; j++){
  83.    for (k=0; k<wC.length; k++){
  84.     var clr=wC[i]+wC[j]+wC[k];
  85.     w(' <td style="background:#'+clr+';height:12px;width:12px" onmouseover=vC("#'+clr+'") onclick=sC("#'+clr+'")></td>'+"\n");
  86.    }
  87.   }
  88.   w('</tr>');
  89.  }
  90.  w("</table></div>\n"); //end color table,COLOR_FORM
  91.  w("</div>\n"); //controls end
  92.  w('<div class="wzCtrl" id="showWYSIWYG'+idTa+'" style="display:none"><input type="button" onclick="showDesign();" value="'+t("Hide HTML")+'">');
  93.  tagButs();
  94.  w('</div>'+"\n");
  95.  w('<iframe style="border:1px inset ButtonShadow;width:100%;height:'+taHeight+'" src="javascript:;" id="whizzy'+idTa+'"></iframe></div>'+"\n", true); //finally write content to whizzy container
  96.  var startHTML="<html>\n<head>\n<style>td,th{border:1px dotted #888}</style>\n";
  97.  if(cssFile){startHTML += '<link media="all" type="text/css" href="'+cssFile+'" rel="stylesheet">\n'}
  98.  startHTML += '</head>\n<body id="'+idTa+'" style="background-image:none">\n'+tidyD(taContent)+'</body>\n</html>';
  99.  oW=o("whizzy"+idTa).contentWindow;
  100.  var d=oW.document;
  101.  try{d.designMode="on";} catch(e){ setTimeout('oW.designMode="on";', 100);}
  102.  d.open(); d.write(startHTML); d.close();

continua…