feat: iframe 工具栏增加新标签页打开
在内嵌页工具栏「强制刷新」旁增加「新标签页」按钮,以 noopener 方式打开当前 iframe 地址,便于无法内嵌时在独立标签访问。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -156,6 +156,14 @@
|
||||
>
|
||||
强制刷新
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-secondary btn-toolbar-refresh"
|
||||
id="frame-open-tab"
|
||||
title="在新标签页打开当前页面"
|
||||
>
|
||||
新标签页
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="frame-wrap">
|
||||
@@ -208,6 +216,7 @@
|
||||
var cards = document.querySelectorAll(".service-card[data-url]");
|
||||
var btnRefresh = document.getElementById("frame-refresh");
|
||||
var btnForceRefresh = document.getElementById("frame-force-refresh");
|
||||
var btnOpenTab = document.getElementById("frame-open-tab");
|
||||
var btnBack = document.getElementById("frame-back-overview");
|
||||
var btnBackHub = document.getElementById("frame-back-hub");
|
||||
var btnHubLogin = document.getElementById("frame-hub-login");
|
||||
@@ -626,6 +635,31 @@
|
||||
};
|
||||
}
|
||||
|
||||
function getCurrentFrameUrl() {
|
||||
var u = "";
|
||||
try {
|
||||
if (
|
||||
frame.contentWindow &&
|
||||
frame.contentWindow.location &&
|
||||
frame.contentWindow.location.href &&
|
||||
frame.contentWindow.location.href !== "about:blank"
|
||||
) {
|
||||
u = frame.contentWindow.location.href;
|
||||
}
|
||||
} catch (e) {}
|
||||
if (!u || u === "about:blank") {
|
||||
u = frame.src || currentOpenUrl || currentBaseUrl;
|
||||
}
|
||||
if (!u || u === "about:blank") return "";
|
||||
return u;
|
||||
}
|
||||
|
||||
function openInNewTab() {
|
||||
var u = getCurrentFrameUrl();
|
||||
if (!u) return;
|
||||
window.open(u, "_blank", "noopener,noreferrer");
|
||||
}
|
||||
|
||||
function showDashboard() {
|
||||
currentBaseUrl = "";
|
||||
currentOpenUrl = "";
|
||||
@@ -723,6 +757,12 @@
|
||||
forceReloadUrl();
|
||||
});
|
||||
|
||||
if (btnOpenTab) {
|
||||
btnOpenTab.addEventListener("click", function () {
|
||||
openInNewTab();
|
||||
});
|
||||
}
|
||||
|
||||
btnBack.addEventListener("click", function () {
|
||||
showDashboard();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user