Foros del Web » Programando para Internet » Javascript »

No se ejecuta JavaScript si pego otro

Estas en el tema de No se ejecuta JavaScript si pego otro en el foro de Javascript en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 10/09/2011, 09:49
Avatar de JuJoGuAl  
Fecha de Ingreso: julio-2009
Ubicación: Venezuela
Mensajes: 754
Antigüedad: 15 años, 3 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…
  #2 (permalink)  
Antiguo 10/09/2011, 10:09
Avatar de JuJoGuAl  
Fecha de Ingreso: julio-2009
Ubicación: Venezuela
Mensajes: 754
Antigüedad: 15 años, 3 meses
Puntos: 19
Respuesta: No se ejecuta JavaScript si pego otro

Código Javascript:
Ver original
  1. if(oW.addEventListener){oW.addEventListener("keypress", kb_handler, true)}
  2.  else{d.body.attachEvent("onpaste",function(){setTimeout('cleanUp()',10)})}
  3.  addEvt(d,"mouseup", whereAmI); addEvt(d,"keyup", whereAmI); addEvt(d,"dblclick", doDbl);
  4.  taObject = o(idTa);
  5.  o("CONTAINER"+idTa).removeChild(o(idTa));
  6.  o("CONTAINER"+idTa).appendChild(taObject);
  7.  idTa=null;
  8. }
  9. function whizzywig(controls){
  10.  var i,ta=document.getElementsByTagName('TEXTAREA');
  11.  for (i=0;i<ta.length;i++){
  12.   if(!ta[i].id){ta[i].id=ta.name}
  13.   makeWhizzyWig(ta[i].id,controls);
  14.  }
  15. }
  16. function addEvt(o,e,f){if(wn.addEventListener){o.addEventListener(e, f, false)}else{o.attachEvent("on"+e,f)}}
  17. function doDbl(){if(papa.nodeName == 'IMG'){doImage()}else{if(papa.nodeName=='A'){doLink()}}}
  18. function makeButton(button){// assemble the button requested
  19.  var butHTML, ucBut=button.substring(0,1).toUpperCase();
  20.  ucBut += button.substring(1);
  21.  ucBut=t(ucBut.replace(/_/g,' '));
  22.  if(!document.frames && (button=="spellcheck")){return}
  23.  if(o(idTa).nodeName!="TEXTAREA" && button=="html"){return}
  24.  if(!buttonExt){buttonExt='.gif'}
  25.  if (buttonPath == "textbuttons"){butHTML='<button type=button onClick=makeSo("'+button+'")>'+ucBut+"</button>\n"}
  26.  else{butHTML='<button  title="'+ucBut+'" type=button onClick=makeSo("'+button+'")>'+(btn[button]!=undefined?'<div style="width:'+btn._w+'px;height:'+btn._h+'px;background-image:url('+btn._f+');background-position:-'+btn[button]+'px 0px"></div>':'<img src="'+buttonPath+button+buttonExt+'" alt="'+ucBut+'" onError="this.parentNode.innerHTML=this.alt">')+'</button>\n'}
  27.  w(butHTML)
  28. }
  29. function fGo(id){return '<div id="'+id+'_FORM'+idTa+'" unselectable="on" style="display:none" onkeypress="if(event.keyCode==13) {return false;}"><hr>'+"\n"}//new form
  30. function fNo(txt,go){//form do it/cancel buttons
  31.  return ' <input type="button" onclick="'+go+'" value="'+txt+'"> <input type="button" onclick="hideDialogs();" value='+t("Cancel")+"></div>\n";
  32. }
  33. function makeSelect(select){
  34.  var values,options,h,i;
  35.  if (select == 'formatblock'){
  36.  h="Heading";
  37.  values=["<p>", "<p>", "<h1>", "<h2>", "<h3>", "<h4>", "<h5>", "<h6>", "<address>",  "<pre>"];
  38.  options=[t("Choose style")+":", t("Paragraph"), t(h)+" 1 ", t(h)+" 2 ", t(h)+" 3 ", t(h)+" 4 ", t(h)+" 5 ", t(h)+" 6", t("Address"), t("Fixed width<pre>")];
  39.  }else if (select == 'fontname') {
  40.   values=["Arial, Helvetica, sans-serif", "Arial, Helvetica, sans-serif","'Arial Black', Helvetica, sans-serif", "'Comic Sans MS' fantasy", "Courier New, Courier, monospace", "Georgia, serif", "Impact,sans-serif","'Times New Roman', Times, serif", "'Trebuchet MS',sans-serif", "Verdana, Arial, Helvetica, sans-serif"];
  41.   options=[t("Font")+":", "Arial","Arial Black", "Comic", "Courier", "Georgia", "Impact","Times New Roman", "Trebuchet","Verdana"]
  42.  }else if(select == 'fontsize'){
  43.   values=["3", "1", "2", "3", "4", "5", "6", "7"];
  44.   options=[t("Font size")+":", "1 "+t("Small"), "2", "3", "4", "5", "6", "7 "+t("Big")]
  45.  }else{
  46.   values=vals[select];
  47.   options=opts[select]
  48.  }
  49.  w('<select id="'+select+idTa+'" onchange="doSelect(this.id);">'+"\n");
  50.  for (i=0;i<values.length;i++){w(' <option value="' + values[i] + '">' + options[i] + "</option>\n")}
  51.  w("</select>\n")
  52. }
  53. function tagButs(){
  54.  w('<input type="button" onclick=\'doTag("<h1>")\' value="H1" title="<H1>"><input type="button" onclick=\'doTag("<h2>")\' value="H2" title="<H2>"><input type="button" onclick=\'doTag("<h3>")\' value="H3" title="<H3>"><input type="button" onclick=\'doTag("<h4>")\' value="H4" title="<H4>"><input type="button" onclick=\'doTag("<p>")\' value="P" title="<P>"><input type="button" onclick=\'doTag("<strong>")\' value="S" title="<STRONG>" style="font-weight:bold"><input type="button" onclick=\'doTag("<em>")\' value="E" title="<EM>" style="font-style:italic;"><input type="button" onclick=\'doTag("<li>")\' value="&bull;&mdash;" title="<LI>"><input type="button" onclick=\'doTag("<a>")\' value="@" title="<A HREF= >"><input type="button" onclick=\'doTag("<img>")\' value="[&hearts;]" title="<IMG SRC= >"><input type="button" onclick=\'doTag("<br />")\' value="&larr;" title="<BR />">');
  55. }
  56. function xC(c,o){return oW.document.execCommand(c,false,o)}
  57. function makeSo(cm,op){
  58.  hideDialogs();
  59.  oW.focus();
  60.  if(dobut[cm]) {insHTML(dobut[cm]); return;}
  61.  if (/Firefox/.test(navigator.userAgent)) {xC("styleWithCSS",cm=="hilite")}
  62.  if(cm=="justify"){cm="full"}
  63.  if("leftrightcenterfull".indexOf(cm)!=-1){cm="justify"+cm}
  64.  else if(cm=="number"){cm="insertorderedlist"}
  65.  else if(cm=="bullet"){cm="insertunorderedlist"}
  66.  else if (cm=="rule"){cm="inserthorizontalrule"}
  67.  switch(cm){
  68.   case "color":o('cf_cmd'+idTa).value="forecolor"; if(textSel()){s('COLOR_FORM'+idTa)} break;
  69.   case "hilite":o('cf_cmd'+idTa).value=cm; if(textSel()){s('COLOR_FORM'+idTa)} break;
  70.   case "image":doImage(); break;
  71.   case "link":doLink(); break;
  72.   case "html":showHTML(); break;
  73.   case "table":doTable(); break;
  74.   case "delete_row":doRow('delete','0'); break;
  75.   case "add_row_above":doRow('add','0'); break;
  76.   case "add_row_below":doRow('add','1'); break;
  77.   case "delete_column":doCol('delete','0'); break;
  78.   case "add_column_before":doCol('add','0'); break;
  79.   case "add_column_after":doCol('add','1'); break;
  80.   case "table_in_cell":hideDialogs(); s('TABLE_FORM'+idTa); break;
  81.   case "clean":cleanUp(); break;
  82.   case "spellcheck":spellCheck(); break;
  83.   case "fullscreen":fullscreen(); break;
  84.   default:xC(cm,op); break;
  85.  }
  86.  oW.focus();
  87. }
  88. function doSelect(selectname) {  
  89.  var idx=o(selectname).selectedIndex;
  90.  var selected=o(selectname).options[idx].value;
  91.  o(selectname).selectedIndex=0;
  92.  selectname=selectname.replace(idTa,"");
  93.  if (" _formatblock_fontname_fontsize".indexOf('_'+selectname) > 0) {
  94.   var cmd=selectname;
  95.   oW.focus();
  96.   xC(cmd,selected);
  97.  } else {
  98.   insHTML(selected);
  99.  }  
  100.  oW.focus();
  101. }
  102. function vC(colour){
  103.  if(!colour){colour=o('cf_color'+idTa).value}
  104.  o('cPrvw'+idTa).style.backgroundColor=colour;
  105.  o('cf_color'+idTa).value=colour
  106. }
  107. function sC(color) {
  108.  hideDialogs();
  109.  var cmd=o('cf_cmd'+idTa).value;
  110.  if(!color){color=o('cf_color'+idTa).value}
  111.  if(rng){rng.select();}
  112.  if(cmd=="hilite"){try{xC("hilitecolor",color)}catch(e){xC("backcolor",color)}}
  113.  else{xC(cmd,color)}
  114.  oW.focus();
  115. }
  116. function doLink(){
  117.  if(textSel()){
  118.   if(papa.nodeName=='A'){o("lf_url"+idTa).value=papa.href}
  119.   s('LINK_FORM'+idTa)
  120.  }
  121. }
  122. function insertLink(url) {
  123.  if (rng){rng.select()}
  124.  var a,i,mk='http://whizzy.wig/mark',
  125.  URL=url ? url : o("lf_url"+idTa).value;
  126.  if (URL.replace(/ /g,"")===""){xC('Unlink',null)}else{
  127.   xC('CreateLink',mk);
  128.   a=oW.document.body.getElementsByTagName("A");
  129.   for (i=0;i<a.length;i++){
  130.    if (a[i].href==mk){a[i].href=URL; if(o("lf_new"+idTa).checked){a[i].target="_blank"}break}
  131.   }
  132.  }
  133.  hideDialogs();
  134. }
  135. function doImage(){
  136.  if (papa && papa.nodeName == 'IMG'){
  137.   o("if_url"+idTa).value=papa.src;
  138.   o("if_alt"+idTa).value=papa.alt;
  139.   var position = papa.style.cssFloat?papa.style.cssFloat:papa.style.styleFloat;
  140.   o("if_side"+idTa).selectedIndex=(position=="left")?1:(position=="right")?2:0;
  141.   o("if_border"+idTa).value=papa.style.border?papa.style.border:papa.border>0?papa.border:0;
  142.   o("if_margin"+idTa).value=papa.style.margin?papa.style.margin:papa.hspace>0?papa.hspace:0;
  143.  }
  144.  s('IMAGE_FORM'+idTa);
  145. }
  146. function insertImage(URL, side, border, margin, alt) {
  147.  hideDialogs();
  148.  if(!URL){URL=o("if_url"+idTa).value}
  149.  if (URL) {
  150.   if (!alt){alt=o("if_alt"+idTa).value ? o("if_alt"+idTa).value: URL.replace(/.*\/(.+)\..*/,"$1")}
  151.   img='<img alt="' + alt + '" src="' + URL +'" ';
  152.   if(!side){side=o("if_side"+idTa).value}
  153.   if((side=="left") || (side=="right")){align='float:'+side+';'}else{align=''}
  154.   if(!border){border=o("if_border"+idTa).value}
  155.   if(border.match(/^\d+$/)){border+='px solid'}
  156.   if(!margin){margin=o("if_margin"+idTa).value}
  157.   if(margin.match(/^\d+$/)){margin+='px'}
  158.   if(border || margin){img+=' style="border:'+border+';margin:'+margin+';'+align+ '"'}
  159.   img+='/>';
  160.   insHTML(img)
  161.  }
  162. }
  163. function doTable(){ //show table controls if in a table, else make table
  164.  if(trail && trail.indexOf('TABLE') > 0){s('TABLE_CONTROLS'+idTa)}
  165.   else{s('TABLE_FORM'+idTa)}
  166. }
  167. function doRow(toDo,below) {
  168.  var pa=papa,tRow,tCols,newRow,newCell;
  169.  while(pa.tagName != "TR"){pa=pa.parentNode}
  170.  tRow=pa.rowIndex;
  171.  tCols=pa.cells.length;
  172.  while(pa.tagName != "TABLE"){pa=pa.parentNode}
  173.  if(toDo=="delete"){pa.deleteRow(tRow)}
  174.  else{
  175.   newRow=pa.insertRow(tRow+parseInt(below,10));//1=below 0=above
  176.    for(i=0;i<tCols;i++){
  177.     newCell=newRow.insertCell(i);
  178.     newCell.innerHTML="#";
  179.    }
  180.  }
  181. }
  182. function doCol(toDo,after) {//insert or delete a column
  183.  var pa=papa,tCol,tRows,i,newCell;
  184.  while(pa.tagName != 'TD'){pa=pa.parentNode}
  185.  tCol=pa.cellIndex;
  186.  while(pa.tagName != "TABLE"){pa=pa.parentNode}
  187.  tRows=pa.rows.length;
  188.  for(i=0;i<tRows;i++){
  189.   if(toDo=="delete"){pa.rows[i].deleteCell(tCol)}
  190.   else{
  191.    newCell=pa.rows[i].insertCell(tCol+parseInt(after,10));//if after=0 then before
  192.    newCell.innerHTML="#";
  193.   }
  194.  }
  195. }
  196. function makeTable() {
  197.  hideDialogs();
  198.  var rows=o('tf_rows'+idTa).value, cols=o('tf_cols'+idTa).value, border=o('tf_border'+idTa).value, head=o('tf_head'+idTa).value, table,i,j;
  199.  if ((rows>0)&&(cols>0)){
  200.   table='<table border="'+border+'">';
  201.   for (i=1;i<=rows;i++){
  202.    table=table+"<tr>";
  203.    for (j=1;j<=cols;j++){
  204.     if (i==1){
  205.      if(head=="1"){table += "<th>Title"+j+"</th>"}//Title1 Title2 etc.
  206.      else{table+="<td>"+j+"</td>"}
  207.     }
  208.     else if(j==1){table+="<td>"+i+"</td>"}
  209.    else{table += "<td>#</td>"}
  210.    }
Continua…
  #3 (permalink)  
Antiguo 10/09/2011, 10:13
Avatar de JuJoGuAl  
Fecha de Ingreso: julio-2009
Ubicación: Venezuela
Mensajes: 754
Antigüedad: 15 años, 3 meses
Puntos: 19
Respuesta: No se ejecuta JavaScript si pego otro

Código Javascript:
Ver original
  1. table+ "</tr>";
  2.   }
  3.   table+=" </table>";
  4.   insHTML(table)
  5.  }
  6. }
  7. function doWin(URL) {
  8.  ppw=wn.open(URL,'popWhizz','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480,top=100');
  9.  ppw.focus();
  10. }
  11. function spellCheck(){
  12.  try {
  13.   var axo=new ActiveXObject("ieSpell.ieSpellExtension");
  14.   axo.CheckAllLinkedDocuments(document);
  15.  } catch(e) {
  16.   if(e.number==-2146827859) {
  17.   if(confirm("ieSpell is not installed on your computer. \n Click [OK] to go to download page."))
  18.    {wn.open("http://www.iespell.com/download.php","DownLoad")}
  19.   }else{
  20.    alert("Error Loading ieSpell: Exception " + e.number)
  21.   }
  22.  }
  23. }
  24. function getWinSize(){
  25.  var winW=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.clientWidth;
  26.  var winH=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight;
  27.  return {w:winW,h:winH}
  28. }
  29. function fullscreen() {  //Enable or disable fullscreen
  30.  var container=o("CONTAINER"+idTa);
  31.  if(!isFullscreen()) {
  32.   if(document.body.style.overflow){document.body.style.overflow="hidden";}else{document.documentElement.style.overflow="hidden";}
  33.   document.body.style.visibility="hidden";
  34.   container.style.visibility="visible"
  35.   container.style.position="absolute";
  36.   container.style.top=(window.pageYOffset?window.pageYOffset:document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop) + "px";
  37.   container.style.left="0";
  38.   container.style.width=getWinSize().w+"px";
  39.   container.style.height=getWinSize().h+"px";
  40.   o("whizzy"+idTa).style.backgroundColor="#fff";
  41.   o("whizzy"+idTa).style.height=getWinSize().h-o("CONTROLS"+idTa).offsetHeight+"px";
  42.  }
  43.  else {
  44.   if(document.body.style.overflow){document.body.style.overflow="visible";}else{document.documentElement.style.overflow="";}
  45.   document.body.style.visibility="visible";
  46.   container.style.position="relative";
  47.   container.style.top=o(idTa).style.top?o(idTa).style.top:"0px";
  48.   container.style.left=o(idTa).style.left?o(idTa).style.left:"0px";
  49.   container.style.width=taOrigSize[idTa].w;
  50.   container.style.height="auto";
  51.   o("whizzy"+idTa).style.backgroundColor="transparent";
  52.   o("whizzy"+idTa).style.height=taOrigSize[idTa].h;
  53.  }
  54. }
  55. function getDir() { //Detect current whizzywig directory
  56.  var base=location.href,e=document.getElementsByTagName('base'),i;
  57.  for(i=0;i<e.length;i++){
  58.   if(e[i].href){base = e[i].href}
  59.  }
  60.  e=document.getElementsByTagName('script');
  61.  for(i=0;i<e.length;i++) {
  62.   if(e[i].src && /(^|\/)whizzywig\.js([?#].*)?$/i.test(e[i].src)){
  63.    return e[i].src.replace(/whizzywig\.js/i.exec(e[i].src),'')
  64.   }
  65.   else if(e[i].src && /(^|\/)whizzywig[^\/].*?\.js([?#].*)?$/i.test(e[i].src)){
  66.    return e[i].src.replace(/whizzywig[^\/].*?\.js/i.exec(e[i].src), '')
  67.   }
  68.  }
  69.  return '';
  70. }
  71. function isFullscreen(){
  72.  if(o("CONTAINER"+idTa).style.width==getWinSize().w+"px"){return true}
  73.  return false
  74. }
  75. function hideDialogs() {
  76.  h('LINK_FORM'+idTa); h('IMAGE_FORM'+idTa); h('COLOR_FORM'+idTa); h('TABLE_FORM'+idTa); h('TABLE_CONTROLS'+idTa);
  77. }
  78. function showDesign(){
  79.  oW.document.body.innerHTML=tidyD(o(idTa).value);
  80.  h(idTa); h('showWYSIWYG'+idTa); s('CONTROLS'+idTa); s('whizzy'+idTa);
  81.  if(o("whizzy"+idTa).contentDocument){o("whizzy"+idTa).contentDocument.designMode="on"}
  82.  oW.focus()
  83. }
  84. function showHTML(){
  85.  o(idTa).value=tidyH(oW.document);
  86.  h('CONTROLS'+idTa); h('whizzy'+idTa); s(idTa); s('showWYSIWYG'+idTa);
  87.  if(isFullscreen()){
  88.   o(idTa).style.width=getWinSize().w+"px";
  89.   o(idTa).style.height=(getWinSize().h-o('showWYSIWYG'+idTa).offsetHeight)+"px";
  90.   o(idTa).style.borderWidth = "0px"
  91.  }else{
  92.   o(idTa).style.position="relative";
  93.   o(idTa).style.width=taOrigSize[idTa].w;
  94.   o(idTa).style.height=taOrigSize[idTa].h;
  95.   o(idTa).style.borderWidth="1px"
  96.  }
  97.  o(idTa).focus()
  98. }
  99.  
  100. function syncTextarea(){//tidy up before we go-go
  101.  for (var i=0;i<whizzies.length;i++){
  102.   var t=whizzies[i];
  103.   var d=o("whizzy"+t).contentWindow.document;
  104.   if (o(t).style.display=='block'){d.body.innerHTML=o(t).value}
  105.   var ret=(o(t).nodeName!="TEXTAREA") ? o('wzhid_'+o(t).id) : o(t);
  106.   ret.value=tidyH(d)
  107.  }
  108. }
  109. function cleanUp(){xC("removeformat",null); tidyH(oW.document)}
  110. function tidyD(h){//FF designmode likes <B>,<I>...
  111.  h=h.replace(/<(\/?)strong([^>]*)>/gi,"<$1B$2>").replace(/<(\/?)em>/gi,"<$1I>");
  112.  return h
  113. }
  114. function tidyH(d){//attempt valid xhtml
  115.  function lc(str){return str.toLowerCase()}
  116.  function qa(str){return str.replace(/(\s+\w+=)([^"][^>\s]*)/gi,'$1"$2"');}
  117.  function sa(str){return str.replace(/("|;)\s*[A-Z-]+\s*:/g,lc);}
  118.  var sz=['medium','xx-small','x-small','small','medium','large','x-large','xx-large'],
  119.  fs=d.getElementsByTagName("FONT"),i,ih;
  120.  for (i=0;i<fs.length;i++){
  121.   if (fs[i].face) {fs[i].style.fontFamily = fs[i].face; fs[i].removeAttribute('face')}
  122.   if (fs[i].size) {fs[i].style.fontSize = sz[fs[i].size]; fs[i].removeAttribute('size')}
  123.   if (fs[i].color) {fs[i].style.color = fs[i].color; fs[i].removeAttribute('color')}
  124.  }
  125.  ih=d.body.innerHTML;
  126.  ih=ih.replace(/(<\/?)FONT([^>]*)/gi,"$1span$2")
  127.  .replace(/(<\/?)[B](\s+[^>]*)?>/gi, "$1strong$2>")
  128.  .replace(/(<\/?)[I](\s+[^>]*)?>/gi, "$1em$2>")
  129.  .replace(/<\/?(COL|XML|ST1|SHAPE|V:|O:|F:|F |PATH|LOCK|IMAGEDATA|STROKE|FORMULAS)[^>]*>/gi, "")
  130.  .replace(/\bCLASS="?(MSOw*|Apple-style-span)"?/gi,"")
  131.  .replace(/<[^>]+=[^>]+>/g,qa) //quote all atts
  132.  .replace(/<(TABLE|TD|TH|COL)(.*)(WIDTH|HEIGHT)=["'0-9A-Z]*/gi, "<$1$2")//no fixed size tables (%OK) [^A-Za-z>]
  133.  .replace(/<([^>]+)>\s*<\/\1>/g, "")
  134.  .replace(/><(H|P|D|T|BLO|FOR|IN|SE|OP|UL|OL|LI|SC)/gi,">\n<$1")adjacent blocks
  135.  .replace(/(<BR ?\/?>)([^\r\n])/gi,"$1\n$2")
  136.  .replace(/([^\n])<(P|DIV|TAB|FOR)/gi,"$1\n\n<$2")
  137.  .replace(/([^\n])<\/(UL|OL|DL|DIV|TAB|FOR)/gi,"$1\n</$2")
  138.  .replace(/([^\n])(<\/TR)/gi,"$1\n $2") //end row
  139.  .replace(/\n<(BLO|LI|OP|TR|IN|DT)/gi,"\n <$1")
  140.  .replace(/\n<(TD|TH|DD)/gi,"\n  <$1")
  141.  .replace(window.location.href+'#','#')
  142.  .replace(/<(IMG|INPUT|BR|HR|LINK|META)([^>]*)>/gi,"<$1$2 />")
  143.  .replace(/(<\/?[A-Z]*)/g,lc)
  144.  .replace(/STYLE="[^"]*"/gi,sa);
  145.  return ih
  146. }
  147. function kb_handler(e){
  148.  var cmd=false, prm=false,k;
  149.  if(e && (e.ctrlKey && e.keyCode==e.DOM_VK_V)||(e.shiftKey && e.keyCode==e.DOM_VK_INSERT))
  150.   {setTimeout('cleanUp()',10)}
  151.  else if(e && e.keyCode==13 && !e.shiftKey &&papa.nodeName=="BODY"){cmd="formatblock";prm="<p>"}
  152.  else if(e && e.ctrlKey){
  153.   k=String.fromCharCode(e.charCode).toLowerCase();
  154.   cmd=(k=='b')?'bold':(k=='i')?'italic':(k=='l')?'link':(k=='m')?'image':false;
  155.  }
  156.  if(cmd){
  157.   makeSo(cmd,prm);
  158.   e.preventDefault();
  159.   e.stopPropagation()
  160.  }
  161. }
  162. function doTag(html){
  163.  var url,close='',before,after;
  164.  if(!html){html=prompt("Enter some HTML or text to insert:", "")}
  165.  o(idTa).focus();
  166.  if(html=='<a>'){
  167.   url=prompt("Link address:","http://");
  168.   html='<a href="'+url+'">'
  169.  }
  170.  if(html=='<img>'){
  171.   url=prompt("Address of image:","http://");
  172.   var alt=prompt("Description of image");
  173.   html ='<img src="'+url+'" alt="'+alt+'">';
  174.  }
  175.  if(html.indexOf('<')===0 && html.indexOf('br') != 1 && html.indexOf('img') != 1)
  176.   {close=html.replace(/<([a-z0-6]+).*/,"<\/$1>")}
  177.  if(html != '<strong>' && html != '<em>'){close+='\n'}
  178.  if (document.selection){
  179.   sel=document.selection.createRange();
  180.   sel.text=html+sel.text+close
  181.  }else{
  182.    before=o(idTa).value.slice(0,o(idTa).selectionStart);
  183.    sel=o(idTa).value.slice(o(idTa).selectionStart,o(idTa).selectionEnd);
  184.    after=o(idTa).value.slice(o(idTa).selectionEnd);
  185.    o(idTa).value =before+html+sel+close+after
  186.  }
  187.  o(idTa).focus()
  188. }
  189. function insHTML(html){//insert HTML at current selection
  190.  if(!html){html=prompt(t("Enter some HTML or text to insert:"), "")}
  191.  if(html.indexOf('js:')===0){
  192.   try{eval(html.replace(/^js:/,''))} catch(e){}
  193.   return
  194.  }
  195.  whereAmI();
  196.  try {xC("inserthtml",html+sel)}
  197.  catch(e){if (document.selection) {
  198.   if(papa&&papa.nodeName=='IMG'){papa.outerHTML=html+papa.outerHTML;}
  199.   else if(rng){rng.select(); rng.pasteHTML(html+rng.htmlText)}
  200.  } }
  201. }
  202. function whereAmI(e){
  203.  if(!e){e=wn.event}
  204.  var mu=e&&e.type=='mouseup',pa,id;
  205.  if (msIE){
  206.   oW.document.getElementsByTagName("body")[0].focus();
  207.   sel=oW.document.selection;
  208.   rng=sel.createRange();
  209.   papa=mu?e.srcElement:(sel.type == "Control")?rng.item(0):rng.parentElement();
  210.  }else{
  211.   sel=oW.getSelection();sn=sel.anchorNode;
  212.   papa=mu?e.target:(sn.nodeName == '#text')?sn.parentNode:sn;
  213.  }
  214.  pa=papa;
  215.  trail=papa.nodeName;
  216.  while(!pa.nodeName.match(/^(HTML|BODY)/) && pa.className!="wzCtrl"){
  217.   pa=pa.parentNode;
  218.   trail=pa.nodeName+'>'+trail
  219.  }
  220.  if(pa.className=="wzCtrl"){trail=sel=rng=null}
  221.  id=pa.nodeName=="HTML" ? pa.getElementsByTagName("BODY")[0].id : pa.id.replace("CONTROL","");
  222.  c(id);
  223.  wn.status=id+":"+trail;
  224.  if(trail.indexOf('TABLE')>0){s('TABLE_CONTROLS'+idTa)}else{h('TABLE_CONTROLS'+idTa)}
  225. }
  226. function c(id){//set current whizzy
  227.  if(id==="" || whizzies.join().indexOf(id)=='-1'){return}
  228.  if (id!=idTa){
  229.   idTa=id;
  230.   try {oW=o("whizzy"+id).contentWindow;} catch(e){alert('set current: '+id)}
  231.   if(oW){if(oW.focus){oW.focus()}wn.status=oW.document.body.id}
  232.  }
  233. }
  234. function w(str,finalize){
  235.  if(!w.temp){w.temp=""}
  236.  w.temp+=str;
  237.  if(finalize){
  238.   o("CONTAINER"+idTa).innerHTML+=w.temp;
  239.   w.temp=""
  240.  }
  241. }
  242. function textSel(){if(sel && sel.type != "None" && sel.type != "Caret"){return true}else{alert(t("Select some text first")); return false}}
  243. function s(id){o(id).style.display='block'}
  244. function h(id){o(id).style.display='none'}
  245. function o(id){return document.getElementById(id)}//get element by ID
  246. function t(key){return (wn.language && language[key]) ? language[key] :  key;}

Alguien podria decirme que esta pasando? Porque no hay el probleman

Etiquetas: ejecuta, html
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:15.