Ewon TechForum
Providing technical solutions to technical requests



Script to force logoff/logout in viewON
simon Offline
eWON Support
#1
Not Solved
Hi Guys,

If you just want to create a button to be able to change the user logged in viewON, you can use this viewON Script/Javascript.

This will force the logoff of the current user and prompt for new credentials

Code:
        var d = '111111111111',
       hostParts = window.location.href.split('/');
       url = hostParts[0] + '//'+d+':'+d+'@';

       if (window.location.href.indexOf("m2web.talk2m.com") > -1)     
         url += hostParts[2]  + '/' + hostParts[3]  + '/' +  hostParts[4]  +'/Ast/MainAst.shtm?nocache='+(new Date().getTime());
       else
         url += hostParts[2]  + '/Ast/MainAst.shtm?nocache='+(new Date().getTime());

       $.ajax(
       {
            type: "get",
            url: url,
            timeout: 15000,
            error: function(jqXHR, status)
            {
                 window.location.href = '../../usr/login.html';
            },
            // should not occur
            success: function(jqXHR, status)
            {
                 window.location.href = '../../usr/login.html';
            }
         });
         
Reply

ziozetti Offline
Senior Member
#2
This is great Simon!
This script is very useful when you want to test user's rights.

I just changed both:

Code:
              window.location.href = '../../usr/login.html';

with:

Code:
              window.location.href = '../../usr/viewon/Home.shtm';

Where Home is name of the view where button is placed and it works like a charm.
Reply

simon Offline
eWON Support
#3
Oh yes ! Forgot that :-)
Good point !
Thx for your loyalty Wink
Reply




Possibly Related Threads…
13-06-2025, 08:28 AM
Last Post: ccasellas
10-06-2025, 06:52 PM
Last Post: itstomis
28-03-2024, 11:59 AM
Last Post: dezanvu
  Viewon webpage Modbus Started by Arno_HPP
4 Replies - 2.800 Views
13-09-2023, 08:22 AM
Last Post: Jean-Yves
26-05-2023, 11:25 AM
Last Post: simon
17-05-2023, 03:51 PM
Last Post: simon
  ViewON Questions Started by ts12
7 Replies - 4.394 Views
06-04-2023, 02:29 AM
Last Post: ts12
30-03-2023, 03:09 AM
Last Post: carlosbantiling
  VIEWS on viewON Started by oscarchavez97
4 Replies - 3.157 Views
25-02-2023, 02:11 AM
Last Post: simon
14-11-2022, 12:42 PM
Last Post: simon



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy