我有一個函數可以在 iFrame 中調用另一個函數,如下所示:function globalFunc(value) { //select and add ID to the iFrame const preloading_iFrame = $("iframe[src*='http://127.0.0.1:8887/Components/preloading/index.html']"); preloading_iFrame.attr("id","preloadingID"); // call iframe's function document.getElementById('preloadingID').contentWindow.iframeFunc(value);}由于我想執行globalFunc多次,我想知道我們是否可以id在第一次添加 iframe 后繞過添加到 iframe。諸如檢查 iframe 是否具有preloadingIDas 之類的東西,id然后不要再添加它!有什么解決辦法嗎?
使用 JQuery 檢查 iframe 是否具有特定 id
ABOUTYOU
2022-06-09 19:19:03