IEウィンドウを閉じてSession_javascriptスキルをクリアするための解決策
//function window.onunload() { alert('これはあなたがしなければならないことです、Webページを閉じてください! '); location = 'SessionClear.aspx' }
//function window.onbeforeunload() {alert('これはあなたがしなければならないことです, 閉じる ページは以前に作成されました ') }
関数 window.onunload() {
" // ユーザーが異常終了したときにトリガーする必要があるアクション Location = 'Handler1.ashx';
}
}
Handler1.ashx:
System.Web を使用;
System.Web.Services を使用;
System.Web.SessionState を使用;
namespace WebApplication1
{ ///
/// $codebehindclassname$ の概要説明
///
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Handler1: IHttpHandler,IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{ context.Response.ContentType = "text/plain";
context.Session.Abandon();
session.Clear() ;
}
public bool IsReusable
{
{
return false;
}
}
}
}
説明:
幸いなことに、ユーザーが Alt F4 を使用するとき、タイトル バーを右クリックして閉じるとき、タイトル バーをダブルクリックするとき、または閉じるボタンを直接押したときのイベントをキャプチャできる方法を、インターネット上でついに見つけました。もちろん、タスクバーに最小化して閉じてもキャプチャできません。
Instructions:
window.screenLeft = 10000 border width (2×2) = 10004
window.screenTop = 10000 toolbar height title bar height = 10097
It should be noted that in onBeforeUnload, these coordinate attributes of the screen are normal values.
screenLeft: Gets the x-coordinate of the upper left corner of the browser client area relative to the upper left corner of the screen.
screenTop: Gets the y coordinate of the upper left corner of the browser client area relative to the upper left corner of the screen.
I guess that a special value will be generated when the form is destroyed. In a click test under normal circumstances, the value will not exceed this value.
The problem now is that using window.location in onBeforeUnload can submit the request to the specified URL normally, but this method cannot be effectively executed in the onUnload event. The solution is to open a new window and close it.
We can write something like this to replace the series of window.locations used in the past. Because the portal involves multiple cross-server website servers. After exiting from the unified entrance, you need to exit sequentially in order to achieve the desired effect of the portal website.
var newWindow;
window.opener=null;
newWindow=window.open(URL,PageName, 'height=0,width=0');
newWindow.opener=null;
newWindow.close();
……
This code has been tested. Do not use window.close in onUnload because the event will be triggered immediately before the object is destroyed. And onBeforeUnload is an event triggered before the page is unloaded.
The so-called clearing is essentially to call the page with the exit function directly by opening a new window. There may be a pause for a second or two when the call is made to close, or the window may be closed on a dedicated exit page. The difference between this page and normal exit and switching back to the homepage is that it will be automatically closed after exiting and can be opened directly without additional control.
[Note] If no judgment is made in window.onUnload, this event will be triggered when the current page changes, such as refreshing the page. Therefore, judgment must be made to capture specific operations in order to block some normal operations.
Continued: How to clear the Session before the user directly closes the window in IE
I explained the implementation idea yesterday, but in actual operation I found that a delay must be added to ensure that the program can be executed normally. The implementation details are attached below, along with a simple time delay function. The code has been tested.
Second, when the window loads or exits, if you want to refresh the browser once, you can do the following:
Refresh on close

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック









Springboot プロジェクトの本番環境のセッションアウト タイムアウトで問題が見つかりました。問題の説明は次のとおりです: テスト環境では、application.yaml を変更することでセッションアウトが構成されていました。別の時間を設定してセッションアウト構成を確認した後、有効期限がリリース時に直接 8 時間に設定され、運用環境に到着しました。しかし、正午にお客様から、プロジェクトの有効期限が短く設定されており、30分操作がないとセッションが期限切れになり、再度ログインが必要になるというフィードバックをいただきました。開発環境の扱いの問題を解決します。springboot プロジェクトには Tomcat が組み込まれているため、プロジェクト内の application.yaml で設定されたセッションアウトが有効になります。本番環境: 本番環境リリースは

セッション障害は通常、セッションの有効期間の期限切れまたはサーバーのシャットダウンによって発生します。解決策: 1. セッションの有効期間を延長する; 2. 永続ストレージを使用する; 3. Cookie を使用する; 4. セッションを非同期的に更新する; 5. セッション管理ミドルウェアを使用する。

PHPSession のクロスドメイン問題の解決策 フロントエンドとバックエンドの分離の開発では、クロスドメイン要求が標準になっています。クロスドメインの問題に対処するときは、通常、セッションの使用と管理が必要になります。ただし、ブラウザーのオリジンポリシーの制限により、デフォルトではセッションをドメイン間で共有できません。この問題を解決するには、いくつかの技術と方法を使用して、セッションのクロスドメイン共有を実現する必要があります。 1. ドメイン間でセッションを共有するための Cookie の最も一般的な使用法

更新後に PHP セッションが消える問題の解決策: 1. 「session_start();」を通じてセッションを開きます; 2. すべてのパブリック設定を PHP ファイルに書き込みます; 3. 変数名は配列の添字と同じにすることはできません。 4. phpinfoでセッションデータの保存パスを確認し、ファイルディレクトリ内のsessioが正常に保存されているか確認してください。

セッション PHP のデフォルトの有効期限は 1440 秒、つまり 24 分です。つまり、クライアントが 24 分を超えて更新されない場合、現在のセッションは期限切れになります。ユーザーがブラウザを閉じると、セッションは終了し、セッションは存在しなくなります。

問題: 今日、プロジェクトで設定タイムアウトの問題が発生し、SpringBoot2 の application.properties への変更が反映されませんでした。解決策:server.* プロパティは、SpringBoot によって使用される埋め込みコンテナーを制御するために使用されます。 SpringBoot は、ServletWebServerFactory インスタンスの 1 つを使用してサーブレット コンテナのインスタンスを作成します。これらのクラスは、server.* プロパティを使用して、制御されるサーブレット コンテナ (tomcat、jetty など) を構成します。アプリケーションが war ファイルとして Tomcat インスタンスにデプロイされる場合、server.* プロパティは適用されません。それらは当てはまりませんが、

1. セッションに基づく SMS ログインの実装 1.1 SMS ログインのフローチャート 1.2 SMS 検証コード送信の実装 フロントエンド リクエストの説明: リクエスト メソッドの説明 POST リクエスト パス /user/code リクエスト パラメータ 電話 (電話番号) 戻り値 バックエンド インターフェイスなし実装: @Slf4j@ ServicepublicclassUserServiceImplextendsServiceImplimplementsIUserService{@OverridepublicResultsendCode(Stringphone,HttpSessionsession){//1。次の場合は携帯電話番号を確認します。

JavaScriptCookies JavaScript Cookie の使用は、設定、購入、手数料、その他の情報を記憶および追跡する最も効果的な方法です。訪問者のエクスペリエンスを向上させるために必要な情報やウェブサイトの統計。 PHPCookieCookie は、クライアント コンピューターに保存され、追跡目的で保持されるテキスト ファイルです。 PHP は HTTP Cookie を透過的にサポートします。 JavaScript Cookie はどのように機能しますか?サーバーは、訪問者のブラウザに Cookie の形式でデータを送信します。ブラウザは Cookie を受け入れることができます。存在する場合、それは訪問者のハードドライブにプレーンテキストレコードとして保存されます。さて、訪問者がサイト上の別のページに到達すると、
