簡體   English   中英

單擊按鈕后如何打開新的HTML選項卡

[英]How to open new HTML tab after clicking on the button

我的登錄頁面帶有一些功能按鍵。

在此處輸入圖片說明

當我單擊“ Send Money按鈕時,它將在同一選項卡中打開sendMoney.html 代碼如下,

$("#sendMoney").click(function () {
    var address = $('#address').find(":selected").text();
    location.href = 'sendMoney.html#' + address;

});

如何在新標簽頁中打開sendMoney.html

要執行所需的操作,可以使用window.open() 盡管顧名思義,它將打開一個彈出窗口,但實際上該請求將重定向到所有現代瀏覽器中的新標簽頁。 嘗試這個:

$("#sendMoney").click(function () {
    var address = $('#address').find(":selected").text();
    window.open('sendMoney.html#' + address);
});
$("#sendMoney").click(function () {
    var address = $('#address').find(":selected").text();
    window.open('sendMoney.html#' + address);
});

代替使用window.location,使用window.open("your link"); 使用window.location不可能做到這一點。

您可以<a> button text here <a/>使用<a> button text here <a/>制作按鈕,並將屬性目標用作_blank以在新標簽頁中打開頁面

要么

您可以使用window.open()函數作為

window.open(URL, name,)

名稱的值可以是

  • 空白-URL已加載到新窗口中。 這是默認值

  • _parent-URL已加載到父框架

  • _self-URL替換當前頁面

  • _top-URL替換了可能加載的所有框架集。name-窗口的名稱(注意:該名稱未指定新標題的名稱。
    窗口)

您需要使用window.open() ,它將在大多數新瀏覽器中打開新選項卡。 這是更新的代碼:

$("#sendMoney").click(function () {
    var address = $('#address option:selected').text();
    window.open('sendMoney.html#' + address);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM