我想在用户单击父页面上的图像并重定向到新标签页中的子页面后重定向父页面,之后5秒后父页面重定向到xyz页面。请帮助它如何发生?
<a href="karloshopflipkart.php?param=<?php echo $_SESSION['user_id'] ?>" id="flip" target
='_blank'></a>
<!-- cHild page to which page redirected on clicking image -->
<?php
session_start();
require_once("navig.php");
if(isset($_SESSION['user_id'])) {?>
<?php
require_once('connect.php');
$dbb = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
or die('Error communicating to MySQL server.');
$para=$_SESSION['user_id'];
if(isset($_GET['param'])){
$coola=$_GET['param'];
$querye = "INSERT INTO orderdata(user_id, store_used) ".
"VALUES ('$coola', 'Flipkart')";
mysqli_query ($dbb, $querye);
mysqli_close($dbb);
}
?>
<script>
setTimeout(function () {
window.location.href="http://dl.flipkart.com/dl/?affid=caretechc&affExtParam1=<?php echo $_SESSION['user_id'] ?>"; // the redirect goes here
},5000);
</script>
<div id="wrapper">
<div id="container2">
<div id="loader-wrapper">
<div id="loader"></div>
</div>
<style>
答案 0 :(得分:1)
以下是我如何使用Javascript:
<script type="text/javascript">
window.onload = function() {
document.getElementById("image_id).onclick = function() {
var redirectInCurrent = 'same_old.php';
var openInNew = "new_tab.php";
window.open(openInNew);
setTimeout(function(){
window.location.href = redirectInCurrent;
}, 5000);
});
};
};
</script>
window.open()
将在新标签页中打开子页面,而window.location.href
会在5000毫秒后将父页面重定向到redirectInCurrent
中的网址。