How can i call my js function on desk onload?

how can i call my js function on desk onload???

Hi:

Use hooks.py on your custom app.

app_include_js = “yourfile.js”

Hope this helps!

Hey, @nikita_sharma may you try to elaborate, do you want to add a js function on form.

If so, you can do this with hooks.
Go into the hooks file of your app and under below this comment there is explanation on how to do it # include js in doctype views

thanks for your response @imbra actually i have a js function that i want to run after login… if you knowhow it is posible please help me…

i want to run my js function after login… thanks @avc

What will the JS do after login?

it will set the latitude longitude of user

One possible approach:

If you need to access geolocation from server side …

  • Use .js (declare it in hooks.py, as mentioned above) to get coordinates . This .js runs every time browser loads desk. Call to python method passing the geo location to make your thing … or store user, datetime and geo information on a doctype.

  • From server get last geo info for this user from doctype, or directly on the call received from frontend.

Is really ugly, but could works :sweat_smile:
Hope this helps.

1 Like