Trang web này sẽ có chức năng hạn chế trong khi chúng tôi trải qua bảo trì để cải thiện trải nghiệm của bạn. Nếu một bài viết không giải quyết được vấn đề của bạn và bạn muốn đặt câu hỏi, chúng tôi có cộng đồng hỗ trợ của chúng tôi đang chờ để giúp bạn tại @FirefoxSupport trên Twitter và /r/firefox trên Reddit.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

A known bug? target="_blank" and window.close() do no longer work together since Firefox 72

  • 5 trả lời
  • 1 gặp vấn đề này
  • 1 lượt xem
  • Trả lời mới nhất được viết bởi Maximilian

more options

Assume you create a new window (pop-up) using javascript and have its content be something like this:

<html>
<body>
  <form action="some_action.php" target="_blank"> 
     ... some form fields ... 

     <button onclick="window.close()">
        submit in new tab & close pop-up
     </button>
  </form> 

  <a href="some_page.php" target="_blank" onclick="window.close()">
     open link in new tab & close pop-up 
  </a>
</body>
</html>


If you click the button "submit in new tab & close pop-up" the following should happen:

  1. Firefox submits the form in a new tab (because target="_blank" is set in the <form>)
  2. The pop-up closes itself (because onclick="window.close()" is set)

And if you click the link "open link in new tab & close pop-up" the following should happen:

  1. Firefox opens the link in a new tab (because target="_blank" is set in the <a>)
  2. The pop-up closes itself (because onclick="window.close()" is set)

However, what happens instead is this:

  1. Firefox only opens an empty tab, i.e. the submission of the form / the opening of the link fails
  2. The pop-up closes itself

This clearly seems to be a bug, right? Is this a known problem? I tested it with older versions and the problem apparently was introduced relatively recently with Firefox 72. More precisely, the form submission bug was introduced with Firefox 72 Beta 1 and the link opening bug was introduced with Firefox 72 Beta 7.

In Chrome and Internet Explorer both cases work as expected.

Assume you create a new window (pop-up) using javascript and have its content be something like this: <pre> &lt;html&gt; &lt;body&gt; <form action="some_action.php" target="_blank"> ... some form fields ... <button onclick="window.close()"> submit in new tab & close pop-up </button> </form> &lt;a href="some_page.php" target="_blank" onclick="window.close()"&gt; open link in new tab & close pop-up &lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </pre> If you click the button "submit in new tab & close pop-up" the following should happen: # Firefox submits the form in a new tab (because target="_blank" is set in the <form>) # The pop-up closes itself (because onclick="window.close()" is set) And if you click the link "open link in new tab & close pop-up" the following should happen: # Firefox opens the link in a new tab (because target="_blank" is set in the <a>) # The pop-up closes itself (because onclick="window.close()" is set) However, what happens instead is this: # Firefox only opens an '''empty''' tab, i.e. the submission of the form / the opening of the link fails # The pop-up closes itself This clearly seems to be a bug, right? Is this a known problem? I tested it with older versions and the problem apparently was introduced relatively recently with Firefox 72. More precisely, the form submission bug was introduced with Firefox 72 Beta 1 and the link opening bug was introduced with Firefox 72 Beta 7. In Chrome and Internet Explorer both cases work as expected.

Được chỉnh sửa bởi Maximilian vào

Tất cả các câu trả lời (5)

more options

Oh no, the commenting system messed up my HTML code. Is there a way to format code as code?

more options

Okay, I edited the code above, it should be displayed correctly now.

Được chỉnh sửa bởi Maximilian vào

more options

Hello maximilian.schlederer,

please read the given statement I hope solve your problem :

This is a example of form in PHP link

The button form attribute
<form action="/action_page.php" method="get" id="nameform"> <label for="fname">First name:</label> <input type="text" id="fname" name="fname">

<label for="lname">Last name:</label> <input type="text" id="lname" name="lname"> </form>

The button below is outside the form element, but still part of the form.

<button type="submit" form="nameform" value="Submit">Submit</button>


note: PHP file is must in same folder or full path where you link

<a target="_blank|_self|_parent|_top|framename">

_blank: Opens the linked document in a new window or tab.

thank you your problem is fixed then reply me

more options

Arman Khan, your comment is unrelated to my problem. Please see my original post and my updated comment with the properly formatted code sample.

more options

Giải pháp được chọn