Redirect page based on User in Javascript

I used this functionality in Oracle business intelligence report.
In OBIEE there are so many user and Responsibilities.
so our requirement is based on User selection it should redirect to the page.

Javascript:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
 
<p id="user1"  onClick="myFunction(this.id)">Bhavesh</p>
 
<p id="user2"  onClick="myFunction(this.id)">Aditya</p>
 
<p id="user3"  onClick="myFunction(this.id)">Abhilash</p>
 
<form>
    <input type="text" name="in" id="output">
 
    <input id="id1" name="user" type="button" value="Submit" onclick="link(this.id);"/>
</form>
 
 
<script>
    function myFunction(id)
    {
        document.getElementById("output").value = document.getElementById(id).innerHTML;
    }
 
    function link(id)
    {
 
        user =document.getElementById("output");
 
        // alert(user.value);
 
        if (user.value=="Bhavesh")
        {
            window.open('http://javaforlearn.com/');
        }
 
        else if (user.value=="Abhilash")
        {
            window.open('http://www.abhisphotography.com/');
        }
 
        else if (user.value=="Aditya")
        {
            window.open('http://www.website.com/page');
        }
 
        else
        {
            alert('wrong user');
        }
 
    }
 
</script>
 
</body>
</html>

Output:

Redirect to the specific page based on User.

Leave a Reply

Your email address will not be published. Required fields are marked *