El siguiente código se ejecuta y se pasa en IE8, y se produjo un error en IE9: Copie el código de la siguiente manera:
document.createElement ('<iframe id = "yige-org-iframe" src = "yige.org.logo.gif" style = "posición: absoluto; top: 0; izquierda: 0; ancho: 1px; altura: 1px; visibilidad: hidden;"> </iframe>');
Solicitud de error: Excepción: script5022: DOM Excepción: Invalid_Character_err (5)
Análisis de ideas:
Paso 1: Compatible con IE9, Firefox, Opera, Safari y otros navegadores;
La copia del código es la siguiente: var iframe = document.createElement ("iframe");
iframe.setAttribute ("id", "yui-history-iframe");
iframe.setattribute ("src", "../../images/defaults/transparent-pixel.gif");
iframe.setAttribute ("estilo", "Posición: Absoluto; arriba: 0; izquierda: 0; ancho: 1px; altura: 1px; visibilidad: oculta;");
Paso 2: Compatible con IE6-8: ya que IE6-8 no puede modificar el atributo de nombre del iframe
La copia del código es la siguiente:
var ofRame = isie? document.createElement ("<iframe name =/" " + this._framename +"/">"): document.createElement ("iframe");
ofRame.name = "iframname";
Solución integral:
La copia del código es la siguiente:
var isie = (document.all)? verdadero: falso; // Aquí hay solo un juicio simple sobre si es, es decir. Para el juicio detallado del navegador: consulte la detección del tipo de navegador
var ua = navigator.useragent.tolowercase (). Match (/msie ([/d.] +)/) [1];
if (ua == "9.0") {
isie = falso;
}
var ofRame = isie? document.createElement ("<iframe name = /" " + this._framename +" / ">"): document.createElement ("iframe"); ofRame.name = "iframename";
// ================================================================ ======================================================================
function aJaxPost (formid, showid, waitid, showidclass, submitbtn, record) {
var waitid = typeof waitid == 'Undefined' || Waitid === NULL? showid: (waitid! == ''? Waitid: '');
var showIdClass =! showIdClass? '': showIdClass;
var ajaxframeid = 'Ajaxframe';
var ajaxframe = $ (AjaxFrameId);
var formTarget = $ (formid) .target;
var handleLeresult = function () {
var s = '';
var evalued = false;
showloading ('Ninguno');
intentar {
S = $ (AjaxFrameId) .ContentWindow.Document.xmlDocument.Text;
} catch (e) {
intentar {
S = $ (AjaxFrameId) .contentwindow.document.documentelement.firstchild.wholetext;
} catch (e) {
intentar {
S = $ (AjaxFrameId) .ContentWindow.document.documentelement.firstchild.nodeValue;
} catch (e) {
s = 'error interno, no puede mostrar este contenido';
}
}
}
if (s! = '' '&& s.indexof (' ajaxerror ')! = -1) {
evalscript (s);
evaluado = verdadero;
}
if (showIdClass) {
$ (showid) .classname = showIdClass;
if (SubtBtn) {
SubsittBtn.disable = false;
}
}
if (! Evaled && (typeof ajaxerror == 'Undefined' ||! Ajaxerror)) {
ajaxinnerhtml ($ (showid), s);
}
ajaxerror = nulo;
if ($ (formid)) $ (formid) .target = formTarget;
if (typeof record == 'function') {
recordar();
} demás {
eval (recordar);
}
if (! Evaled) evalscript (s);
ajaxframe.loading = 0;
$ ('append_parent'). removeChild (ajaxframe);
};
if (! Ajaxframe) {
intentar {
AjaxFrame = document.createElement ('<iframe name = "' + ajaxframeid + '" id = "' + ajaxframeid + '"> </iframe>');
} catch (e) {
ajaxframe = document.createElement ('iframe');
AjaxFrame.name = AjaxFrameId;
AjaxFrame.id = AjaxFrameId;
}
ajaxframe.style.display = 'ninguno';
ajaxframe.loading = 1;
$ ('append_parent'). AppendChild (Ajaxframe);
} else if (ajaxframe.loading) {
devolver falso;
}
_AttacheVent (Ajaxframe, 'Load', HandLeresult);
showloading ();
$ (formid) .target = ajaxframeid;
$ (formid) .Action += '& inajax = 1';
$ (formid) .submit ();
devolver falso;
}