そのため、時計が0になったときに.phpファイルを取得するカウントダウンタイマーがあります。唯一の問題は、phpファイルが新しいウィンドウで開いていることです。どうにかしてページ下部に表示させたいと思っています。
JavaScript や AJAX については何も知りません。phpとhtmlのみです。誰が初心者に何をすべきかを示すことができますか?
<!--START COUNTDOWN TIMER SCRIPT--> <br> <script type="text/javascript"> window.onload = function() { countDown('my_div1', 'timerunout.php', 4); } function countDown(elID, output, seconds) { var elem = document.getElementById(elID), start = new Date().getTime(), end = start+seconds*1000, timer = setInterval(function() { var now = new Date().getTime(), timeleft = end-now, timeparts; if( timeleft < 0) { document.location.href = output; clearInterval(timer); } else { timeparts = [Math.floor(timeleft/60000),Math.floor(timeleft/1000)%60]; if( timeparts[1] < 10) timeparts[1] = "0"+timeparts[1]; elem.innerHTML = "When the Clock hits Zero...<br> "+timeparts[0]+":"+timeparts[1]; } },250); // the lower this number, the more accurate the timer. 250 recommended } </script> <center> <font color="#FF0000"><b><h1> <div id="my_div1"> </div> </h1></b></font> </center> <!--END COUNTDOWN TIMER SCRIPT-->
わかりましたので、index.php にカウントダウン タイマーがあり、0 になると... AJAX を使用してページの下部に別の php ファイルが開きます。これをtimerunout.phpと呼びましょう
問題はこれです...そのPHPファイルはリンクです。そのリンクの最後には、アフィリエイト ID が添付されている必要があります。
そのアフィリエイト ID は、誰かが index.php のアドレスの末尾にユーザー名を入力したときにのみ検出されます。助言がありますか?
index.php のコードは次のとおりです。
window.onload = function() { countDown('my_div1', 'timerunout.php', 4); }function countDown(elID, output, seconds) { var elem = document.getElementById(elID); start = new Date().getTime(), end = start+seconds*1000, timer = setInterval(function() { var now = new Date().getTime(), timeleft = end-now, timeparts; if( timeleft < 0) { //This code creates the AJAX object, which will then be used to send it. var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } //This code parameterizes the object to point at your page in an asynchronous way. xmlhttp.open("GET","timerunout.php?s1=username",true); xmlhttp.send(); //Once all parameters are set, send it on it's way. //Callback. Once the request is in one of it's stages, this will be called. xmlhttp.onreadystatechange=function() { //Request done and fetching the page successful? if (xmlhttp.readyState==4 && xmlhttp.status==200) { //Sets the HTML of my_div1 to whatever was in timerunout.php elem.innerHTML=xmlhttp.responseText; } } clearInterval(timer); } else { timeparts = [Math.floor(timeleft/60000),Math.floor(timeleft/1000)%60]; if( timeparts[1] < 10) timeparts[1] = "0"+timeparts[1]; elem.innerHTML = "When the Clock hits Zero...<br> "+timeparts[0]+":"+timeparts[1]; } } ,250); // the lower this number, the more accurate the timer. 250 recommended } </script> <center> <div id="my_div1"></div> </center> <!--END COUNTDOWN TIMER SCRIPT-->
ここにtimerunout.phpがあります
// // Maybe check $s1 is indeed valid // $newurl = sprintf('/join.php?id=%s', urlencode($_GET['s1'])); $coaching = sprintf('/live/webinar-register.php?id=%s',
urlencode($_GET['s1'])); ?>
基本的に私が言いたいのは、index.php では
username
、この行はユーザーがアドレスバーに入力したものから来ている必要があるということです。
xmlhttp.open("GET","timerunout.php?s1=username",true);