开发者

How to find DOM element IF logged in or not

开发者 https://www.devze.com 2023-03-05 23:31 出处:网络
I am using jQuery on my site and I need to make some jQuery IF statements for IF logged in DO THIS else DO THIS (For instance logging in would change the header text to \'My Account\').I don\'t really

I am using jQuery on my site and I need to make some jQuery IF statements for IF logged in DO THIS else DO THIS (For instance logging in would change the header text to 'My Account'). I don't really know how to read the DOM tree to see what element or node I would be calling. Does anyone have experience with this?

On Product Pages I currently have jQuery code starting with:

 jQuery(function(){
if (typeof(global_Current_ProductCode) !="undefined")

is there something I could find on my site that is like this:

jQuery(function(){
    if (typeof(global_Current_LoggedIn) !="undefined")

Here is a link to my demo site i'm trying to modify

Perhaps I can use FF or Chrome to help find what I'm looking for in the DOM, I really don't know w开发者_开发百科here to start or at least start by telling me what exactly (typeof(global_Current_ProductCode) !="undefiend") is doing??


I'm very wary about this - it sounds like you are trying to use Javascript (front-end) code for authentication logic. This is a massive security hole and you should ALWAYS use secure back-end code to authenticate your users!

If you are only concerned with manipulating DOM elements such as changing text like you say, that's easily achievable in JS but again, would be much better if the markup was generated on the server and sent to the front-end.

0

精彩评论

暂无评论...
验证码 换一张
取 消