Web Analytics Made Easy -
StatCounter Javascript - how to check if IE window exists with a specific URL! - CodingForum

Announcement

Collapse
No announcement yet.

Javascript - how to check if IE window exists with a specific URL!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript - how to check if IE window exists with a specific URL!

    Hi All,

    I am not an expert in Javascript.

    Can I detect if 1 or more sessions of a website are open?

    for example, if a session with port 7005 is open like this one below, then I want to assign the next port to this user in the second window of browser



    the next IE window should appear like this:



    or


    Please advise.

    Thanks

    Yasar

  • #2
    Client-side javascript won't allow script access to other windows or tabs (unless those windows or tabs were directly created by the script in question - which I believe from your question is NOT the case here).

    That type of check would need to be done on the server side. I imagine you could do that pretty easily by IP address, if that helps.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. –G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

    Comment


    • #3
      Thanks for inputs,

      I have a redirector application written in a JSP page.

      This contains an array that holds 4 URLs in the code mentioned below.

      100+ users access it to login to maximo.

      I want to make sure if 1 user launches two login sessions i.e., 2 IE windows, both of them should be different ports, otherwise system will not work.

      Can you put some more light on this and give some guideline what my approach should be?

      Code:
      <%@page import="java.net.HttpURLConnection"%>
      <%@page import="java.net.URL"%>
      
      
      <%
      
         String[] maxServer = { "90.97.8.0:7005/maximo", "90.97.8.0:7006/maximo" , "90.97.8.0:7007/maximo", "90.97.8.0:7008/maximo"};
         String Server = "";
         String errServer = "90.97.8.0:7001";
         
         String accessCount = (String) application.getAttribute("accessCount");
         if (accessCount == null) {
            accessCount = "0";
         }
      
         int i = Integer.parseInt(accessCount);;
         int sIndex = 0;
         String path ="";
         int counter=0;
         boolean error=false;
         while(counter < maxServer.length){
            try {
               sIndex = i % (maxServer.length );
               Server = maxServer[sIndex];
               path = "http://" + Server + "/webclient/login/login.jsp";
               URL url = new URL(path);
               HttpURLConnection conn = (HttpURLConnection) url.openConnection();
               conn.setRequestMethod("POST");
               conn.setDoOutput(true);
               conn.setDoInput(true);
               conn.connect();
               conn.disconnect();
               conn=null;
               break;
            } catch (Exception e) {
               i++;
               if(counter==maxServer.length-1){
                  error=true;
                  break;
               }
               counter++;
            }
         }
         application.setAttribute("accessCount", String.valueOf(i + 1));   
         response.setStatus(301);
         response.setHeader( "Connection", "close" );
         
         if(!error){
            response.setHeader( "Location", "http://" + Server + "/webclient/login/login.jsp");
         } else {
            response.setHeader( "Location", "http://" + errServer + "/maximo/webclient/login/error.html" );
         }
      %>

      Comment

      Working...
      X
      😀
      🥰
      🤢
      😎
      😡
      👍
      👎