The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
4 posters

    Javascript Pages Question

    Eden Alexandria
    Eden Alexandria
    Forumember


    Female Posts : 36
    Reputation : 1
    Language : English

    Solved Javascript Pages Question

    Post by Eden Alexandria Sat 8 Aug 2015 - 3:25

    When adding a jQuery page, what would I introduce it with, within a post? Just <script> tags? Or would I have to place the entire page into a Javascript page in the Admin Panel?


    Last edited by Eden Alexandria on Sun 9 Aug 2015 - 19:52; edited 2 times in total
    Russel
    Russel
    Active Poster


    Male Posts : 1407
    Reputation : 236
    Language : English, Filipino
    Location : Philippines

    Solved Re: Javascript Pages Question

    Post by Russel Sat 8 Aug 2015 - 4:35

    Hi @Eden Alexandria,

    JS codes don't work within a post. We use the Javascipt page in the Admin Panel.
    Eden Alexandria
    Eden Alexandria
    Forumember


    Female Posts : 36
    Reputation : 1
    Language : English

    Solved Re: Javascript Pages Question

    Post by Eden Alexandria Sat 8 Aug 2015 - 22:13

    Alright. Now, would each JS page have to be separate? Or could you have several functions within one page?
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Javascript Pages Question

    Post by SLGray Sat 8 Aug 2015 - 22:16

    What do you mean by page?

    Please change the title of your topic to something that is related to your question/issue, so that other users will be able to find their question/issue using the search engine.



    Javascript Pages Question Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Eden Alexandria
    Eden Alexandria
    Forumember


    Female Posts : 36
    Reputation : 1
    Language : English

    Solved Re: Javascript Pages Question

    Post by Eden Alexandria Sun 9 Aug 2015 - 0:48

    Changed the title. What I mean by page is the javascript management section of the Admin Panel. You of course click on the green button to add a "page" of JS or jQuery. Though you know that already haha xD
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Javascript Pages Question

    Post by SLGray Sun 9 Aug 2015 - 16:38

    It is not called a page, but a JavaScript code.

    Do you mean creating a HTML page?



    Javascript Pages Question Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Eden Alexandria
    Eden Alexandria
    Forumember


    Female Posts : 36
    Reputation : 1
    Language : English

    Solved Re: Javascript Pages Question

    Post by Eden Alexandria Sun 9 Aug 2015 - 17:55

    Nono I meant Javascript. I was just using improper terminology xD But yes, a javascript code is what I am referring to.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Javascript Pages Question

    Post by SLGray Sun 9 Aug 2015 - 19:18

    What specifically are you trying to do?



    Javascript Pages Question Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Eden Alexandria
    Eden Alexandria
    Forumember


    Female Posts : 36
    Reputation : 1
    Language : English

    Solved Re: Javascript Pages Question

    Post by Eden Alexandria Sun 9 Aug 2015 - 19:21

    I'm more or less wondering if I can put more than one "function" into a single code, or if I have to make a different code for each function.
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Javascript Pages Question

    Post by SLGray Sun 9 Aug 2015 - 19:22

    It depends on what each code effects and do.



    Javascript Pages Question Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Javascript Pages Question

    Post by Ange Tuteur Sun 9 Aug 2015 - 19:36

    You can place as many functions as you want in a script. Everything usually gets combined into one file if the placement is "in all the pages"

    Normally when writing JavaScript you'll want to execute it AFTER the desired HTML element is loaded ( or ready ). The JS codes management page executes all code in the <HEAD> section before the document is ready, so people usually start their scripts with a jQuery DOM ready function.

    The basic and shortest syntax for that is :
    Code:
    $(function() {
      // everything else to execute when the DOM is ready
    });

    Where the comment is, is where you'll write your code.

    Depending on what you're doing, you don't always need to use the above. It's mostly meant for if you're manipulating the document. ( e.g. add a specific function to an array of elements, or hiding something )

    If it's just a normal function that will be called later, then you can just add it like this in JS management.
    Code:
    function callMe() {
      alert('You called me ?');
    };
    Eden Alexandria
    Eden Alexandria
    Forumember


    Female Posts : 36
    Reputation : 1
    Language : English

    Solved Re: Javascript Pages Question

    Post by Eden Alexandria Sun 9 Aug 2015 - 19:52

    Ah, I see. That makes sense. Thank you, SLGray and Ange!  :rose: :rose:
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51498
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: Javascript Pages Question

    Post by SLGray Sun 9 Aug 2015 - 21:14

    Topic solved and archived



    Javascript Pages Question Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.

      Current date/time is Sun 22 Sep 2024 - 15:27