# Is there a way to use a native js function in p5?

**URL:** <https://discourse.processing.org/t/is-there-a-way-to-use-a-native-js-function-in-p5/26945>\
**Category:** Beginners\
**Created:** [January 10, 2021, 11:27am UTC](https://discourse.processing.org/t/is-there-a-way-to-use-a-native-js-function-in-p5/26945 "2021-01-10T11:27:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgsantos](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@jgsantos](https://discourse.processing.org/u/jgsantos)\
**Post date:** [January 10, 2021, 11:27am UTC](https://discourse.processing.org/t/is-there-a-way-to-use-a-native-js-function-in-p5/26945/1 "2021-01-10T11:27:36Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

Hi, i’am wondering if it is possible to use native js functions in p5. I need, for example, to use the element.scrollTop property, but i don’t know if i can use it in p5.  
I wan’t to do this: [W3Schools Tryit Editor](https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_scrollleft)  
but i need to have this “y” variable in p5 so i can then use it. I would not mind if i had to do a native js function and then get the variable value on p5, but i don’t know how to do it either.

Can anyone help me?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [January 10, 2021, 11:36am UTC](https://discourse.processing.org/t/is-there-a-way-to-use-a-native-js-function-in-p5/26945/2 "2021-01-10T11:36:58Z")

</div>

Not sure about, the native code, but if you have access to a temporary or permanent location, you can use savestring savetable or any other function to save data which can then be read by any other program.

---

<div class="post-metadata">

**Author:** ![jgsantos](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@jgsantos](https://discourse.processing.org/u/jgsantos)\
**Post date:** [January 10, 2021, 11:58am UTC](https://discourse.processing.org/t/is-there-a-way-to-use-a-native-js-function-in-p5/26945/3 "2021-01-10T11:58:53Z")

</div>

I did it. It is the simplest thing ever, you just have to write the function outside draw 😂  
function myFunction() {  
… (write normal js code)  
}

---

<div class="post-metadata">

**Author:** ![jgsantos](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@jgsantos](https://discourse.processing.org/u/jgsantos)\
**Post date:** [January 10, 2021, 11:59am UTC](https://discourse.processing.org/t/is-there-a-way-to-use-a-native-js-function-in-p5/26945/4 "2021-01-10T11:59:18Z")

</div>

thanks, i ended up finding the solution
