Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/08/2015, 14:23
yagami19
 
Fecha de Ingreso: agosto-2011
Mensajes: 75
Antigüedad: 13 años, 6 meses
Puntos: 0
Respuesta: escribir iframes

Cita:
Iniciado por PHPeros Ver Mensaje
HTML no es JavaScript. No puedes hacer eso. Para ello se usan html entities.
hola

me podrias dar un ejm de como agregar el \

ya q buscando eso de html entities, solo encontre esto pero no se entiende como hacer para agregar \ alos iframes

Código:
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
  return str.replace(/&#(\d+);/g, function(match, dec) {
    return String.fromCharCode(dec);
  });
};

var encodeHtmlEntity = function(str) {
  var buf = [];
  for (var i=str.length-1;i>=0;i--) {
    buf.unshift(['&#', str[i].charCodeAt(), ';'].join(''));
  }
  return buf.join('');
};

var entity = '高级程序设计';
var str = '高级程序设计';
console.log(decodeHtmlEntity(entity) === str);
console.log(encodeHtmlEntity(str) === entity);
// output:
// true
// true