0

Hello I have a slider and at the end of the last slide i want it automaticaly directs visitors to another web page. I was able to get this to work but only if i use exact domain name which i cant use. My job wants me to use a php script that directs them to the web page. This php script works perfectly on my html put when i put the script inside javascript it breaks.

So my question is how do i place the php script inside the javascript below? My job only wants me to use the script because it tracks users and takes them to a specific register page.

BEFORE

    this.element.addEventListener('ampstory:nonextpage', function () {
            window.location.replace('https://www.tutorialrepublic.com/');

            setTimeout('pageRedirect()', 5000);
            Kk(a);
        });

AFTER (WITH PHP CODE THAT BREAKS)

                this.element.addEventListener('ampstory:nonextpage', function () {
                window.location.replace('<?=ht_link('/main.php?a=user.registerfp_mobile&no_header=1&btn_bg_next=b70000')?>');

            setTimeout('pageRedirect()', 5000);
            Kk(a);
        });
jr005
  • 11
  • 8
  • Breaks how exactly? What link does it actually take you to? Or does it crash before that? Does it not execute the PHP? Be more specific about what is happening. – ADyson Apr 30 '21 at 19:49
  • 1
    What does `ht_link` output? – imvain2 Apr 30 '21 at 19:57
  • 1
    PHP executes on the server, JS executes on the client. You cannot mix and match. If you want your JS to get a fresh value from some PHP for whatever, then that's an AJAX/XHR call. Or reimplement the functionality in JS. – Sammitch Apr 30 '21 at 20:02
  • the javascript is used to create the slideshow. after i add in the php link the whole thing breaks – jr005 Apr 30 '21 at 20:09
  • My job wants me to use the php link only because it redirects them to another web page – jr005 Apr 30 '21 at 20:10
  • 1
    `the whole thing breaks`...yes you already said that. And we already said that isn't enough information. Again, please be more specific about the issue. Describe exactly what happens when you try to run it, as I mentioned. What _is_ happening is much more useful information that what _isn't_ happening. If you don't know any more information, then you need to do some basic debugging. We can't run your code or see exactly what "breaks" really means. There could be half a dozen different issues underlying that. – ADyson Apr 30 '21 at 20:26
  • Figured out the answer or the solution. All i needed to do was just update the php script to this '/main.php?a=user.registerfp_mobile&no_header=1&btn_bg_next=b70000' Hopefully this helps someone out – jr005 May 01 '21 at 02:35

0 Answers0