B
blankito1998
Beta
Verificado por Whatsapp
¡Usuario con pocos negocios! ¡Utiliza siempre saldo de Forobeta!
oks pero ahora tengo de nuevo el problema que cuando coloco pantalla grande y la quito el src no se vuelve a colocarPara eliminar el atributojoresdel elementosubodycuando se sale del modo de pantalla completa, simplemente puedes agregar una línea de código en el manejador del eventofullscreenchange. Aquí tienes el código modificado para incluir esta funcionalidad:
### Código Modificado:
JavaScript:$(document).ready(function() { const options = { root: null, threshold: 0.6 }; let loadTimeouts; let observer3 = new IntersectionObserver((entries) => { entries.forEach(entry => { const dataId = entry.target.getAttribute('dataid'); const iframe = entry.target; if (entry.isIntersecting) { // Asignar src si está vacío if (!iframe.src || iframe.src === "") { iframe.src = iframe.getAttribute("data-src"); iframe.onload = function() { $(".laggs[dataid='" + dataId + "']").remove(); attachScale3ClickListener(iframe, dataId); }; } // Controlar y limpiar src de otros iframes loadTimeouts = setInterval(() => { const iframes = document.querySelectorAll(".sessim .octumpro[data-src]"); iframes.forEach(otherIframe => { const otherIframeDataId = otherIframe.getAttribute("dataid"); const currentJores = $("subody").attr("jores"); // Obtener el valor del atributo jores if (otherIframeDataId !== dataId && otherIframeDataId !== currentJores) { // Comprobar si no existe el elemento .laggs con el dataid correspondiente if ($(".laggs[dataid='" + otherIframeDataId + "']").length === 0) { $(otherIframe).removeAttr('src'); // Eliminar el src de otros iframes // Prepend para agregar mensaje de carga $(".freimps" + otherIframeDataId).prepend( '<div class="laggs" dataid="' + otherIframeDataId + '" 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); } else { clearInterval(loadTimeouts); } }); }, options); function attachScale3ClickListener(iframe, dataId) { const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; // Usar delegación de eventos para el botón .scale3 en el iframe $(iframeDocument).on('click', '.scale3', function() { $("subody").attr("jores", dataId); // Aquí puedes agregar la lógica que quieras }); } function observeLogamDivs2() { document.querySelectorAll('.sessim .octumpro[data-src]').forEach(elem => { if (elem instanceof Node) { observer3.observe(elem); } }); } observeLogamDivs2(); let mutationObserver3 = new MutationObserver((mutations) => { mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.nodeType === 1) { const iframes = node.querySelectorAll('.sessim .octumpro[data-src]'); iframes.forEach(iframe => { if (iframe instanceof Node) { observer3.observe(iframe); // Asignar el src nuevamente si es necesario al volver a observar if (!iframe.src || iframe.src === "") { iframe.src = iframe.getAttribute("data-src"); iframe.onload = function() { $(".laggs[dataid='" + iframe.getAttribute('dataid') + "']").remove(); attachScale3ClickListener(iframe, iframe.getAttribute('dataid')); }; } } }); } }); }); }); const targetNode = document.querySelector('.moreinfo'); if (targetNode) { mutationObserver3.observe(targetNode, { childList: true, subtree: true }); } // Manejar el evento de salida de pantalla completa document.addEventListener('fullscreenchange', (event) => { if (!document.fullscreenElement) { // Vuelve a cargar el src, si es necesario, para los iframes visibles document.querySelectorAll(".sessim .octumpro[data-src]").forEach(iframe => { const dataId = iframe.getAttribute('dataid'); if (iframe.src === "") { // Verifica solo si el src está vacío iframe.src = iframe.getAttribute("data-src"); $(".laggs[dataid='" + dataId + "']").remove(); } }); // Eliminar el atributo jores del subbody $("subody").removeAttr("jores"); } }); });
### Cambios Realizados:
1. Eliminación del Atributojores: Se ha añadido la línea$("subody").removeAttr("jores");dentro del bloque del eventofullscreenchange, que se ejecutará cuando dejes el modo de pantalla completa.
### Consideraciones:
- Asegúrate de que el elemento
subodyexista en el DOM y que el atributojoresse aplique correctamente en otras partes de tu código.- Estos cambios garantizarán que cada vez que salgas de pantalla completa, se elimine el atributo
joresdel elementosubody.
Si necesitas más ayuda o ajustes adicionales, ¡házmelo saber!


