[Resolved] Javascript not displaying in a page

Home Forums Support [Resolved] Javascript not displaying in a page

Home Forums Support Javascript not displaying in a page

Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #333948
    Philippe Jourdren

    Hi, I’m a happy blogger using GP Premium.
    I try to put a javascript sequence of that type in a page :

    <script language=’Javascript’ src=’https://fr.divelogs.de/mylatestdivebig.php?user=xxxxxx&#8217; type=’text/javascript’></script>

    Unfortunately, nothing is displayed
    Have you a clue or a solution ?
    Cheers

    #333988
    Leo
    Staff
    Customer Support

    Hi there,

    Where are you adding the code currently?

    Try the wp_head hook: https://docs.generatepress.com/article/hooks-overview/

    #334000
    Philippe Jourdren

    I put this sequence in the content of the page.
    You can view it there :
    http://www.philjourdren.fr/carnet-de-plongees-en-ligne/

    #334009
    Leo
    Staff
    Customer Support

    What is the script for? Generally the it needs to go in wp_head hook.

    #334013
    Philippe Jourdren

    It’s for displaying an image showing a dive profile, which is hosted on divelogs.de

    #334071
    Tom
    Lead Developer
    Lead Developer

    WordPress strips javascript out of the editor.

    Perhaps something like this will help: https://en-ca.wordpress.org/plugins/shortcoder/

    #334094
    Philippe Jourdren

    No it doesn’t, i’ve installed shortcoder plugin, created a shortcode with the javascript sequence, but the shortcode doesn’t work

    #334211
    Tom
    Lead Developer
    Lead Developer

    So the shortcode doesn’t output anything at all when you add it to your content?

    #334356
    Philippe Jourdren

    It displays the test you see when you go the page : http://www.philjourdren.fr/carnet-de-plongees-en-ligne/

    I think I must have done something wrong.
    I created a shortcode called “last-dive”. In the editor i copied :

    <script language=’Javascript’ src=’https://fr.divelogs.de/mylatestdivebig.php?user=lizard2802&#8242; type=’text/javascript’></script>

    And then I saved the shortcode. When I use it, it doesn’t work

    #334560
    Tom
    Lead Developer
    Lead Developer

    And you’re adding [last-dive] to your content?

    #334562
    Philippe Jourdren

    Yes !

    #334567
    Tom
    Lead Developer
    Lead Developer

    Ah, the instructions (https://en-ca.wordpress.org/plugins/shortcoder/) say to add it like this:

    [sc name="my_shortcode"]

    #334655
    Philippe Jourdren

    This is just what i did ! It seems just t oreplace the text of the shortcode with the script
    I don’t understand what’s going on !

    #334841
    Tom
    Lead Developer
    Lead Developer

    Probably worth just creating your own shortcode.

    add_shortcode( 'last_dive', 'last_dive' );
    function last_dive() {
        ob_start();
        ?>
        <script language='Javascript' src='https://fr.divelogs.de/mylatestdivebig.php?user=lizard2802' type='text/javascript'></script>
        <?php
        $ret = ob_get_contents();
        ob_end_clean();
        return $ret;
    }

    Then use: [last_dive]

    #334855
    Philippe Jourdren

    Thanks ! Do i insert this portion of code into the CSS ?

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