久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='rEBJu'></tfoot>
  • <small id='rEBJu'></small><noframes id='rEBJu'>

        <legend id='rEBJu'><style id='rEBJu'><dir id='rEBJu'><q id='rEBJu'></q></dir></style></legend>
      1. <i id='rEBJu'><tr id='rEBJu'><dt id='rEBJu'><q id='rEBJu'><span id='rEBJu'><b id='rEBJu'><form id='rEBJu'><ins id='rEBJu'></ins><ul id='rEBJu'></ul><sub id='rEBJu'></sub></form><legend id='rEBJu'></legend><bdo id='rEBJu'><pre id='rEBJu'><center id='rEBJu'></center></pre></bdo></b><th id='rEBJu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rEBJu'><tfoot id='rEBJu'></tfoot><dl id='rEBJu'><fieldset id='rEBJu'></fieldset></dl></div>
          <bdo id='rEBJu'></bdo><ul id='rEBJu'></ul>

        打開標簽的數量限制

        Restriction on number of opened tabs(打開標簽的數量限制)
        <i id='BDBjW'><tr id='BDBjW'><dt id='BDBjW'><q id='BDBjW'><span id='BDBjW'><b id='BDBjW'><form id='BDBjW'><ins id='BDBjW'></ins><ul id='BDBjW'></ul><sub id='BDBjW'></sub></form><legend id='BDBjW'></legend><bdo id='BDBjW'><pre id='BDBjW'><center id='BDBjW'></center></pre></bdo></b><th id='BDBjW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BDBjW'><tfoot id='BDBjW'></tfoot><dl id='BDBjW'><fieldset id='BDBjW'></fieldset></dl></div>
          1. <tfoot id='BDBjW'></tfoot>

                <tbody id='BDBjW'></tbody>
              <legend id='BDBjW'><style id='BDBjW'><dir id='BDBjW'><q id='BDBjW'></q></dir></style></legend>
                <bdo id='BDBjW'></bdo><ul id='BDBjW'></ul>

                  <small id='BDBjW'></small><noframes id='BDBjW'>

                • 本文介紹了打開標簽的數量限制的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  網頁上有一些鏈接.

                  右鍵單擊有在新選項卡中打開鏈接"選項(瀏覽器選項).

                  On right click there is option of 'open link in new tab'(browser option).

                  我想限制用戶不要打開兩個以上的標簽?我該怎么做?

                  I want to restrict user for not opening more that two tabs? How can i do this?

                  <%@ page language="java" contentType="text/html; charset=UTF-8"
                  pageEncoding="UTF-8"%>
                  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
                  <html>
                  <head>
                  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                  <title>Insert title here</title>
                  </head>
                  <body>
                  <ul>
                  <li><a href="http://localhost:8080/struts_tab/abcForm1.action" oncontextmenu="return false;"><span>First Click[Right Click disabled]</span></a></li>
                  <li><a href="http://localhost:8080/struts_tab/defForm2.action"><span>Second clieck[Not more than 2 tabs]</span></a></li>
                  </ul>
                  </body>
                  </html>
                  

                  推薦答案

                  您不能限制用戶打開新標簽頁.
                  (這讓我想起了沒有按鈕,沒有地址欄,但仍然響應退格和其他事件的舊彈出窗口)

                  You can't restrict the user from opening a new tab.
                  (This reminds me the old pop-ups with no buttons, no address bar, but still responding to backspace and other events)

                  但是,您可以讓您的應用識別打開第三個標簽頁的嘗試,并加載不同的結果(例如錯誤消息),例如:

                  You can however make your app recognize the attempt of opening a third tab, and load a different result like an error message, for example:

                  已達到最大打開標簽限制.請同時使用不超過兩個選項卡.關閉此標簽

                  Maximum open tabs limit reached. Please use no more than two tabs concurrently. close this tab

                  為此,您可以使用 HTML5 sessionStorage.
                  注意:Web 存儲(sessionStoragelocalStorage)現在所有瀏覽器都支持.

                  To do this, you can use HTML5 sessionStorage.
                  Note: Web Storage (sessionStorage and localStorage) is supported on every browser nowadays.

                  這是一個全局對象(sessionStorage),維護一個存儲區域在頁面會話期間可用.頁面會話只要瀏覽器打開并在頁面上存活,就會持續重新加載和恢復.在新標簽頁或窗口中打開頁面會導致將啟動一個新會話.

                  sessionStorage

                  This is a global object (sessionStorage) that maintains a storage area that's available for the duration of the page session. A page session lasts for as long as the browser is open and survives over page reloads and restores. Opening a page in a new tab or window will cause a new session to be initiated.

                  那你就可以了

                  • 如果sessionStorage中不存在,在JSP中生成一個唯一的token,放到sessionStorage中,

                  • if not present in sessionStorage, generate an unique token in JSP, and put it in sessionStorage,

                  $(function(){
                      // Read the ID. If it's null, this is a new tab: 
                      // generate the ID and store it for later.
                      var tabId = sessionStorage.getItem("tabId");
                      if (tabId == null){
                          tabId = Math.random();
                          sessionStorage.putItem("tabId",tabId);
                      }
                  

                • 將其發送回操作

                • send it back to the action

                      // Add the ID to the form (as hidden field), 
                      // so it will be posted back in next submission.
                      $('<input>').attr('type'  , 'hidden')
                                  .attr('name'  , 'tabId')
                                  .attr('value' , tabId)
                      .appendTo('form');
                  });
                  

                  ,可能是 BaseAction 中的 setter,由其他操作擴展,并由 prepare() 讀取,或者 在攔截器中更好;

                  , maybe to a setter in a BaseAction, extendend by the other actions, and read by prepare(), or much better in an Interceptor;

                  把它放在一個集合中,檢查它是否已經包含兩個元素,否則返回錯誤結果,應該全局映射:

                  put it in a collection checking that it doesn't contain already two elements, otherwise return the error result, that should be mapped globally:

                  public String intercept(ActionInvocation actionInvocation) throws Exception {
                      Action action = (Action) actionInvocation.getAction();
                      if(action instanceof LimitedTabsAware){ //interface to identify special actions
                          ActionContext context = actionInvocation.getInvocationContext();
                          Map<String, String[]> request = ((HttpServletRequest) 
                                              context.get(StrutsStatics.HTTP_REQUEST)).getParameterMap();
                  
                          if (request.containsKey("tabId")){              
                              String tabId = (String) request.get("tabId")[0];
                              List<String> openTabs = context.getSession().get("OPEN_TABS_KEY");
                  
                              if (openTabs.contains(tabId)){
                                  return actionInvocation.invoke();                   
                              } else if (openTabs.size()>=2){
                                  return "tabLimitExceeded"; // global result
                              } else {
                                  openTabs.add(tabId);
                                  context.getSession().put("OPEN_TABS_KEY", openTabs);
                                  return actionInvocation.invoke();
                              }
                  
                          } else {
                              throw new IllegalArgumentException("There is no tabId in this request.");
                          }
                      } else {
                          return actionInvocation.invoke();
                      }
                  }
                  

                • 然后您應該找到一種方法來識別選項卡何時關閉(以釋放一個插槽),方法是:

                  Then you should find a way to recognize when a tab get closed (to free one slot), by either:

                  • 優化集合中元素的有效期(如果您有一段時間不使用標簽,會話過期,所以必須做集合中的令牌)
                  • 否則,在您的頁面中放置一個 javascript AJAX 計時器(例如,每 30 秒),發送一個 keep-alive 向動作發出信號以刷新元素的有效性.如果選項卡關閉,則不再發送信號.
                  • timizing the period of validity of the elements in your collection (if you don't use a tab for some time, the session expires, and so must do the token in the collection)
                  • otherwise, putting a javascript AJAX timer in your page (eg. every 30 seconds), that send a keep-alive signal to an action to refresh the validity of the element. If the tab get closed, the signal is not sent anymore.

                  這篇關于打開標簽的數量限制的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)
                    <tbody id='vNLar'></tbody>

                      <tfoot id='vNLar'></tfoot>

                      • <bdo id='vNLar'></bdo><ul id='vNLar'></ul>
                      • <small id='vNLar'></small><noframes id='vNLar'>

                      • <legend id='vNLar'><style id='vNLar'><dir id='vNLar'><q id='vNLar'></q></dir></style></legend>
                        <i id='vNLar'><tr id='vNLar'><dt id='vNLar'><q id='vNLar'><span id='vNLar'><b id='vNLar'><form id='vNLar'><ins id='vNLar'></ins><ul id='vNLar'></ul><sub id='vNLar'></sub></form><legend id='vNLar'></legend><bdo id='vNLar'><pre id='vNLar'><center id='vNLar'></center></pre></bdo></b><th id='vNLar'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vNLar'><tfoot id='vNLar'></tfoot><dl id='vNLar'><fieldset id='vNLar'></fieldset></dl></div>

                            主站蜘蛛池模板: 精品国产乱码一区二区三 | 一区二区三区四区日韩 | 97精品视频在线观看 | 亚洲欧美bt | 欧美在线观看一区二区 | 亚洲日产精品 | 7777在线视频 | 成人在线免费电影 | 麻豆av电影网| 黄篇网址 | 久久久www| 精品一区二区三区av | 一区二区三区视频免费观看 | 四虎永久免费影院 | 欧美日韩精品亚洲 | 亚洲精品乱码久久久久久9色 | 天天射天天操天天干 | 999久久久久久久久 国产欧美在线观看 | 国产精品一区二区在线 | 日韩综合在线播放 | 国产精品18久久久久久白浆动漫 | 日韩精品免费 | 九九九视频在线观看 | 四虎最新视频 | 一级黄色网页 | 综合九九| 天天综合网永久 | 国产在视频一区二区三区吞精 | 亚洲人成在线观看 | 亚洲欧美国产精品一区二区 | 香蕉婷婷| 欧美国产日韩一区二区三区 | av入口 | 午夜资源| 久久精品一区二区三区四区 | 中文字幕av在线播放 | 日韩成人在线免费视频 | 国产精品永久免费视频 | 亚洲精品免费观看 | 国产精品亚洲一区二区三区在线 | 久久久这里只有17精品 |