Permission control-js Determine if there is permission to operate the jump page needs to be added target

Source: Internet
Author: User

Mom eggs, this problem took me 20 minutes, I used to search code spent 18 minutes, I write code has a poor habit, is to copy, what things want to do, on the Internet search others miscellaneous write, take to copy change can

Gee, mom eggs, the whole page, no I can use the information, those blog content a hair like people, you do not move your brain, is it by the number of words to collect money! Most hate this kind of person, you can move, but can't just move without a moment. Look at the first page of the full TM is useless information

It took me 2 minutes to think about it and I took care of it.

There are a lot of ways, maybe very low, but it does meet the demand.

Jsp:

<%
String username = (string) request.getsession (). getattribute ("username");
UserService userservice=new Userserviceimpl ();
int isad= userservice.checkisadmin (username);
%>

<input type= "hidden" name= "ISAdmin" id= "ISAdmin" value= "<%=isAd%>"/>
<li class= "" onclick= "Checkadmin ()" ><span></span><a id= " AddUser "href=" "target=" Rightframe "> Add </a></li>

Js:

<script type= "Text/javascript" >function checkadmin () {var isadmin = $ ("#isAdmin"). Val (); if (isadmin==0) {alert (" You do not have increased privileges, please contact the administrator! ");} else{$ ("#adduser"). attr ("href", "adduser.jsp");}} </script>

Effect:

Permission control-js Determine if there is permission to operate the jump page needs to be added target

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.