Forum Discussion

NehaRana's avatar
12 years ago

IP adress

Hello everyone!!   I am new to Lithium.   I want to put some conditions in javascript on the basis of IP Adress.I have to put that condition into my custom compnent ,so that i can use jquery in i...
  • Claudius's avatar
    12 years ago

    Hi Neha and welcome to Lithosphere,

     

    Usually it's preferrable to handle IP information in Freemarker code. Can you share some more details on what you want to achieve based on the IP address?

     

    If you really really need it in JavaScript it should be possible to have your custom component populate a JavaScript variable with the freemarker one like this:

    <script type="text/javascript">
       var RemoteIP = ${http.request.remoteAddr};
    </script>
    

    ...or if you need this info on every page instead of creating a custom component you can add this code to your Lithium skin's header wrapper.