• I am trying to create reader-controlled small pop ups. Example, someone clicks for more info and a small window opens. The only plug ins I can find are horrible auto-pop ups that collect email addresses etc, I don’t want something like that.

    I used javascript in the <head> tag of my Genesis settings then an onclick code but it just doesn’t work on WP (but does on my non-WP site).

    Any ideas? Is there a way to code this or a plug in? If not to open a page then maybe a small jpg in a small window (not full size).

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • If you copied the jquery code for the pop-up from somewhere on the internet then it probably uses the $ character to reference the jQuery object. However this is not supported in WordPress. You can check if this is the problem by opening your browsers JS console (right click on the page > Inspect Element > Console) and reloading the page. This might reveal the error.

    If this turns out to be the problem then you should try replacing all the $ characters in that code with the word jQuery. The code might start working.

    Thread Starter discoveryattic

    (@discoveryattic)

    Thanks for responding. I suppose I could have included the code, sorry. I don’t see the $ but of course there could be something else.

    Here is the code:
    In head tags:

    <SCRIPT TYPE="text/javascript">
    <!--
    function popup(mylink, windowname)
    {
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, 'width=400,height=200,scrollbars=yes');
    return false;
    }
    //-->
    </SCRIPT>

    In body

    <A HREF="index.html"
       onClick="return popup(this, 'notes')">Link to pop up</A>

    This is sample of it working fine on my regular website https://themetalpeddler.com/test.html

    Can I see the WordPress page where you are trying to use this?

    Thread Starter discoveryattic

    (@discoveryattic)

    Sure – I am just doing it as a test page for now
    https://themodernpioneer.com/test/

    The link ignore the script and is just a regular link.

    I don’t see the onclick part in the source code of this page.

    Thread Starter discoveryattic

    (@discoveryattic)

    It just strips it out. I paste it in, save, publish and when I go back in, it’s gone. ??

    That’s the problem. You can avoid using the onclick thing in the HTML of your post by using javascript’s click event handler.

    Might try editing your profile and disabling the visual editor. Then try and add the code and publish.

    Disabling the visual editor causes it to leave the code alone better.

    Thread Starter discoveryattic

    (@discoveryattic)

    Not sure what the click event handler is?

    I was try disabling visual editor, too. Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Creating small pop up onclick’ is closed to new replies.