[英]I want to click an element using css selectors and open it in a new browser window then send it behind the existing browser window using Jquery or JS
[英]open window behind browser
我有一個網站,一旦有人訪問它,它就會檢查數據庫上的時間戳。 如果時間戳超過4個小時,則會打開一個彈出窗口,該窗口運行數據庫import / update子項來更新數據庫。 然后關閉自己。
這樣做的理由是,它允許瀏覽的人繼續其業務,同時一個單獨的窗口負責更新。
現在,此彈出窗口顯示為焦點。 有沒有一種方法可以使彈出窗口加載到當前瀏覽器窗口的后面,以免干擾用戶導航?
這是主窗口的page_load
子項。
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim connStr As String = ConfigurationManager.ConnectionStrings("SNA_TRT").ConnectionString
Dim sqlConn As SqlConnection
sqlConn = New SqlConnection(connStr)
sqlConn.Open()
Dim strSQL As String = "SELECT TOP 1 [ID], [LASTREFRESH], [BYWHO] FROM [TRT_db_timer] ORDER BY [ID] Desc "
Dim cmd As New SqlCommand(strSQL, sqlConn)
Dim dr As SqlDataReader = cmd.ExecuteReader()
Dim lastupdate As DateTime
Dim currenttime As DateTime = Now()
While dr.Read()
lastupdate = Convert.ToDateTime(dr(ClearNullDs("LASTREFRESH")))
End While
dr.Close()
sqlConn.Close()
Dim ts As TimeSpan = currenttime.Subtract(lastupdate)
Dim dbspan As String = ts.TotalMinutes.ToString()
Dim dsinceup As Integer = ts.Days.ToString + 1
'MsgBox(lastupdate)
'MsgBox(currenttime)
'MsgBox(dbspan)
If dbspan > 240 Then
bodytag.Attributes.Add("onload", "window.open('/trt/admin/importnotice.aspx?DAYS=" & dsinceup & "',null,'height=150, width=350,status=yes, resizable=no, scrollbars=no, toolbar=no,location=no,menubar=no ');")
End If
End If
End Sub
絕對有更好的方法(例如ajax)。
但是要回答你的問題:
function loadpopunder(){
var popunder=window.open(/* popup window parameters */);
popunder.blur();
window.focus(); // focuses the main window.
}
如果您希望在用戶到達站點時進行更新,請使用AJAX或隱藏的iframe。 如果您希望每隔X個小時進行一次更新,而不管用戶是否訪問該站點,請使用CRON作業。 彈出一個窗口來做會加重用戶的負擔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.