B
blankito1998
Beta
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
loadTimeouts = setInterval(() => {Para ajustar tu código y eliminar elsrcde otrosiframessolo si elsrcno es null, puedes realizar el siguiente cambio en la condición que verifica elsrc. A continuación, te muestro el código modificado:
JavaScript:loadTimeouts = setInterval(() => { const iframes = document.querySelectorAll(".sessim .octumpro[data-src]"); iframes.forEach(otherIframe => { const otherIframeDataId = otherIframe.getAttribute("dataid"); if (otherIframeDataId !== dataId) { // Comprobar que el src del iframe no sea null if (otherIframe.src !== null) { $(otherIframe).removeAttr('src'); // Eliminar el src de otros iframes // Prepend para agregar mensaje de carga $(".freimps" + otherIframeDataId).prepend( 'hola<div class="laggs" dataid="' + dataId + '" style="margin-left:10px;display:flex;justify-content:center;justify-items:center;align-content:center;align-items:center;background:#000000;width:calc(100% - 20px);height:100%;float:left;z-index:1;position:absolute;"><img src="../wpp/img/loading-25.gif" loading="lazy" style="width:20px;height:20px;" /></div>' ); } } }); }, 300);
### Explicación de los cambios:
1. Verificación delsrc: Se cambió la condición para que verifique si[otherIframe.src !== null], lo que significa que solo eliminará elsrcsi efectivamente tiene un valor.
2. Eliminación delsrc: Si elsrcno es null, se procede a eliminarlo usando$(otherIframe).removeAttr('src');.
Con estos cambios, losiframescuyosrces null no se les eliminará elsrc. Si necesitas más modificaciones o aclaraciones, ¡hazmelo saber!
const iframes = document.querySelectorAll(".sessim .octumpro[data-src]");
iframes.forEach(otherIframe => {
const otherIframeDataId = otherIframe.getAttribute("dataid");
if (otherIframeDataId !== dataId) {
// Comprobar que el src del iframe no sea null
if (otherIframe.src !== null) {
$(otherIframe).removeAttr('src'); // Eliminar el src de otros iframes
// Prepend para agregar mensaje de carga
$(".freimps" + otherIframeDataId).prepend(
'<div class="laggs" dataid="' + dataId + '" style="margin-left:10px;display:flex;justify-content:center;justify-items:center;align-content:center;align-items:center;background:#000000;width:calc(100% - 20px);height:100%;float:left;z-index:1;position:absolute;"><img src="../wpp/img/loading-25.gif" loading="lazy" style="width:20px;height:20px;" /></div>'
);
}
}
});
}, 300);
porque si esta en f (otherIframe.src !== null) { sigue creando .laggs??


