We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 861
    • 26 Posts
    I've created a popup in js and it's working fine as far as I do not use FU.
    To give you the idea, this is the very simple code:
    <script>
    var doPopUpX = (screen.width/2)-168;
    var doPopUpY = (screen.height/2)-280;
    var pos = "left="+doPopUpX+",top="+doPopUpY;
    
    function doPopUp(){
    doPopUpWindow = window.open("[[~8]]","my_popup","width=336,height=560,"+pos);
    
    }
    </script>
    

    and the call is as follows:
    <a href="javascript:doPopUp()">CLICK and the popup will show</a>


    When Friendly URLs are activated, though, the popup works but it cannot recall the correct page [[~8]] and it defaults to the home page instead. Is there a way to let Friendly URLs work into a js script or is no way to go?

    thx [ed. note: alby54 last edited this post 14 years, 8 months ago.]
      • 31946
      • 116 Posts
      Can you visit the page without javascript when FURL's are turned on? have you defined an alias?
        • 3749
        • 24,544 Posts
        What URL do you see there when you do a "view source" on the page?

        A couple of things to try:

        [[~8 &scheme=`full`]]



        Another approach would be the create the JS dynamically in a snippet, use $modx->makeUrl(8, "", "", "full") to create the URL, then inject the JS with $modx->regClientStartupScript().


        ---------------------------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
        MODx info for everyone: http://bobsguides.com/modx.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Do you have a base meta tag in your template head?
          <base href="[[++site_url]]">
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 861
            • 26 Posts
            Ok ..... I found a solution. The popup, I forgot to mention it in my previous post, is recalled form a page which is inside a container-page. This container displays various contents from many pages and each one of those pages carries a link to a Form-email in a popup format. What was happening was that the recalled URL inherited an extra folder and could not trigger the right page (when it can't find the correct resource it defaults to the home-page). I then simply changed my link as follows:

            function doPopUp(){
            doPopUpWindow = window.open("[[++base_url]][[~8]]","mia_popup","width=336,height=560,"+pos);
             }


            ...and everything worked like a charm. Thx to everyone for suggestions.... next time I'll try Bob's idea of creating js dinamically in a snippet. It sounds very interesting.