I want to close the screen when I press the button on asp.net (VB).

Asked 2 years ago, Updated 2 years ago, 118 views

I opened the screen I created on asp.net(VB) in safari on my iPhone.
I would like to delete the tab when I press the "Exit" button."
"When I press the button, a window appears and says ""Exit"" but
" "When I press ""Close"", the tab does not disappear, and I just return to the original screen."

Designer side programs

<div>
<asp:Button ID="btn_terminate" runat="server" Text="Exit" CssClass="button_shared_preference"/>
</div>

Code Side Programs

Protected Subbtn_terminate_Click (sender As Object, eAs EventArgs) Handles btn_terminate.Click
        ClientScript.RegisterClientScriptBlock(Me.GetType(), "key", "window.alert('Exit''); window.close(), True)
    End Sub

Supplemental 2022-02-18
Here is the general flow of the work.
1. Access the site by loading QR with URL with iPhone camera
  No special action is taken when loading the site
2. Check and input within the site
  *It's not important, so I'll skip the details.
3. Press the "Exit" button to export the contents to the server and close the displayed window
  The window you see is a site that you accessed with "1" and you ran through with "2".
"The problem is the ""Close Window"" part.
Export to the server has been implemented.

asp.net

2022-09-30 19:49

1 Answers

Don't you know what will happen with iPhone Safari or something like that, but don't you usually close it with a browser like that kind of script? JavaScript should only be able to close windows open in JavaScript.

追Additional note 2022/2/18 10:35 】

"It seems that ""Supplemental 2022-02-18"" has been added to the question section, so I will add a response to that below."

1. Access the site by loading QR with URL with iPhone camera
  No special action is taken when loading the site

I understand that it is probably the same as entering the URL of the page in question in the address bar of the browser and making a GET request.If that's the case, in the article introduced by Kunif in the question section,

window.open('about:blank','_self').close();

There seems to be no other way, but whether or not it can be closed as expected depends on the browser.I don't know what will happen with iPhone Safari because I don't have that environment.Why don't you give it a try?

By the way, I tried it in my environment, but only IE11, Firefox 97.0.1 was closed.

Chrome 98.0.4758.102, Edge 98.0.1108.56, Opera 84.0.4316.14 seem to ignore the close, leaving open about:blank.

If you can't use the above script in Safari on your iPhone, I recommend that you give up such a back-to-back approach and think about it in a direct way so that users can manipulate and close it themselves.


2022-09-30 19:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.