Hướng dẫn open new tab html - mở html tab mới

Cách mở một liên kết trong một cửa sổ mới hoặc tab mới.

Để mở một liên kết trong một cửa sổ / tab mới, hãy thêm Target = "_ Blank" bên trong thẻ:

Bạn không thể đặt xem liên kết sẽ được mở trong một cửa sổ mới hoặc tab mới. Nó phụ thuộc vào trình duyệt & NBSP; Cài đặt. & NBSP;

Để mở một liên kết trong một cửa sổ mới, hãy thêm lệnh javascript onclick = "window.open ('text-link.htm', 'name', 'width = 600, height = 400') bên trong thẻ:

Mở trang trong cửa sổ mớionclick="window.open('../html-link.htm','name','width=600,height=400')">Open page in new windowonclick="window.open('../html-link.htm','name','width=600,height=400')">Open page in new window

Xem thảo luận

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

    Cải thiện bài viết

    Lưu bài viết

    Đọcwindow.open() method is used to open a new browser window or a new tab depending on the browser setting and the parameter values.

    Approach: 

    • Bàn luận _blank in the second parameter of the window.open() method. _blank in the second parameter of the window.open() method.
    • Trong HTML, thẻ neo được sử dụng để mở URL theo một tab mới theo cách cơ bản và đơn giản. Thông tin thêm về thẻ này có thể được học từ bài viết này. Tuy nhiên, đôi khi có một nhu cầu phải làm điều tương tự bằng cách sử dụng JavaScript. Trong trường hợp này, phương thức Window.open () chứng minh là hữu ích. Phương thức Window.open () được sử dụng để mở cửa sổ trình duyệt mới hoặc tab mới tùy thuộc vào cài đặt trình duyệt và các giá trị tham số.
    • Để mở một tab mới, chúng ta phải sử dụng _blank trong tham số thứ hai của phương thức window.open ().

    Syntax:

    window.open(URL, '_blank');

    Giá trị trả về của window.open () là một tham chiếu đến cửa sổ mới được tạo hoặc tab hoặc null nếu nó thất bại.

    Không thêm tham số thứ ba vào nó vì nó sẽ dẫn đến việc mở cửa sổ mới thay vì tab

    
    
    
    8
    
    
    
    9
    
    
    
    0

    
    
    
    8

    
    
    
    1
    
    
    
    0
    
    
    
    3
    
    
    
    8
    
    
    
    5
    
    
    
    6
    
    
    
    5
    
    
    
    0
    
    
    
    9
    
    
    
    1
    
    
    
    0

    
    
    
    8

    $("#content a[href^='http://']").attr("target","_blank");
    
    3
    
    
    
    0

    
    
    
    8

    $("#content a[href^='http://']").attr("target","_blank");
    
    6
    $("#content a[href^='http://']").attr("target","_blank");
    
    7
    $("#content a[href^='http://']").attr("target","_blank");
    
    8
    
    
    
    8
    
    
    
    20
    
    
    
    21
    
    
    
    20
    
    
    
    0
    $("#content a[href^='http://']").attr("target","_blank");
    
    8
    
    
    
    25
    
    
    
    3
    
    
    
    9
    $("#content a[href^='http://']").attr("target","_blank");
    
    6
    
    
    
    0

    Ví dụ 1:

    window.open(URL, '_blank');
    7
    window.open(URL, '_blank');
    8

    HTML

    window.open(URL, '_blank');
    0
    
    
    
    8
    
    
    
    35
    
    
    
    0
    window.open(URL, '_blank');
    7
    
    
    
    38

    
    
    
    39
    
    
    
    70

    window.open(URL, '_blank');
    7
    
    
    
    72
    window.open(URL, '_blank');
    0
    
    
    
    9
    
    
    
    35
    
    
    
    0
    
    
    
    9
    $("#content a[href^='http://']").attr("target","_blank");
    
    3
    
    
    
    0
    
    
    
    9
    
    
    
    9
    
    
    
    0

    Output:

    
    
    
    00
    
    
    
    8
    window.open(URL, '_blank');
    2
    window.open(URL, '_blank');
    3
    window.open(URL, '_blank');
    4
    window.open(URL, '_blank');
    5
    
    
    
    00
    
    
    
    8
    window.open(URL, '_blank');
    2
    window.open(URL, '_blank');
    3
    window.open(URL, '_blank');
    4
    window.open(URL, '_blank');
    5
    
    
    
    0

    Không thêm tham số thứ ba vào nó vì nó sẽ dẫn đến việc mở cửa sổ mới thay vì tab

    
    
    
    8
    
    
    
    9
    
    
    
    0

    Ví dụ 1:

    
    
    
    3
    
    
    
    8
    
    
    
    5
    
    
    
    93
    
    
    
    5
    
    
    
    0

    
    
    
    86

    HTML

    
    
    
    8

    $("#content a[href^='http://']").attr("target","_blank");
    
    3
    
    
    
    0

    
    
    
    8

    window.open(URL, '_blank');
    7
    
    
    
    72
    window.open(URL, '_blank');
    0
    
    
    
    9
    
    
    
    35
    
    
    
    0
    
    
    
    9
    $("#content a[href^='http://']").attr("target","_blank");
    
    3
    
    
    
    0
    
    
    
    9
    
    
    
    9
    
    
    
    0

    Output:

    
    
    
    00
    
    
    
    8
    window.open(URL, '_blank');
    2
    window.open(URL, '_blank');
    3
    window.open(URL, '_blank');
    4
    window.open(URL, '_blank');
    5
    
    
    
    0
    The browsers are supported by the window.open() method are listed below:

    • 
      
      
      9
      
      
      
      1
      
      
      
      0
    • $("#content a[href^='http://']").attr("target","_blank");
      
      6
      
      
      
      05
      $("#content a[href^='http://']").attr("target","_blank");
      
      6
      
      
      
      0
      window.open(URL, '_blank');
      0
      
      
      
      8
      window.open(URL, '_blank');
      2
      window.open(URL, '_blank');
      3
      window.open(URL, '_blank');
      4
      
      
      
      03
      
      
      
      044422
      window.open(URL, '_blank');
      0
      
      
      
      8
      
      
      
      35
      
      
      
      0
      window.open(URL, '_blank');
      7
      
      
      
      12
      window.open(URL, '_blank');
      7
      
      
      
      72
      window.open(URL, '_blank');
      0
      
      
      
      9
      
      
      
      35
      
      
      
      0
      
      
      
      9
      $("#content a[href^='http://']").attr("target","_blank");
      
      3
      
      
      
      0
      
      
      
      9
      
      
      
      9
      
      
      
      0
    • Các trình duyệt được hỗ trợ: Các trình duyệt được hỗ trợ bởi phương thức Window.open () được liệt kê dưới đây: The browsers are supported by the window.open() method are listed below:
    • Google Chrome
    • trình duyệt web IE

    Firefox

    Opera


    Cuộc đi sănadding the target=”_blank” attribute. You should insert this after the link address.

    Target = Tiết _ Trống Mở trong tab Trình duyệt mới (hoặc cửa sổ) Thuộc tính đích chỉ định nơi tài liệu được liên kết sẽ mở khi nhấp vào liên kết.Mặc định là cửa sổ hiện tại.Nếu Target = "_ Blank", tài liệu được liên kết sẽ mở trong một tab mới hoặc (trên các trình duyệt cũ hơn) một cửa sổ mới. The target attribute specifies where the linked document will open when the link is clicked. The default is the current window. If target="_blank" , the linked document will open in a new tab or (on older browsers) a new window. The target attribute specifies where the linked document will open when the link is clicked. The default is the current window. If target="_blank" , the linked document will open in a new tab or (on older browsers) a new window.

    Câu trả lời ngắn gọn là: Chỉ cần thêm thuộc tính Target = "_ Blank" vào các liên kết của bạn (thẻ neo).Bây giờ khi khách truy cập của bạn nhấp vào liên kết đó, nó sẽ mở trong một cửa sổ hoặc tab mới (tùy thuộc vào trình duyệt web mà họ đang sử dụng và cách họ cấu hình trình duyệt đó).add a target="_blank" attribute to your links (anchor tags). Now when your visitors click that link, it will open in a new window or tab (depending on which web browser they are using and how they configured that browser).add a target="_blank" attribute to your links (anchor tags). Now when your visitors click that link, it will open in a new window or tab (depending on which web browser they are using and how they configured that browser).