[Resolved] Best way to add 'Javascript' to a page (embedding)?

Home Forums Support [Resolved] Best way to add 'Javascript' to a page (embedding)?

Home Forums Support Best way to add 'Javascript' to a page (embedding)?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1225578
    Andy

    Hi there,

    I have a short form that I usually embed on my landing pages (made with Javascript).

    Looks similar to this:

    <script type="text/javascript">
    /* Short Form */
    var test = {
       "name": {
          "email": ""
       },
    </script>
    <script src="//test.com/js/serve.js"></script>

    How should I embed a code like this on my landing page? Should I use the Classic editor? I don’t want to run into any issues.

    Thank you,
    Andy

    #1225614
    Leo
    Staff
    Customer Support

    Hi there,

    That can usually go into wp_footer hook using a hook element:
    https://docs.generatepress.com/article/hooks-element-overview/

    #1225633
    Andy

    Just clarifying, this isn’t a pop-up though. I’m embedding a single form on 1 page. Similar to embedding a youtube video with iframe.

    Do I still need to use hooks? Thank you

    #1225664
    Leo
    Staff
    Customer Support

    Maybe try the Classic block?

    If not then just go with the classic editor.

    #1225676
    Andy

    Thanks!

    #1225691
    Andy

    Actually Leo, I’m having issues using the Classic block.

    In a previous theme, I was able to add javascript code to my page with a javascript block. Is there any way to add a javascript block like this?

    View post on imgur.com

    #1225700
    Leo
    Staff
    Customer Support

    There isn’t a javascript block from Gutenberg.

    Maybe try the HTML block?

    #1225705
    Andy

    I think that worked, thank you. I’ll test it out.

    #1225707
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.