-6ren">
gpt4 book ai didi

javascript - 用户单击图像几秒钟后如何重定向父页面?

转载 作者:搜寻专家 更新时间:2023-10-31 21:28:54 28 4
gpt4 key购买 nike

我想在用户单击父页面上的图像并重定向到新选项卡中的子页面后重定向父页面,然后在 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>

最佳答案

这是我使用 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 会将父页面重定向到 中的 url 5000 毫秒后 redirectInCurrent

关于javascript - 用户单击图像几秒钟后如何重定向父页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32423988/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com