![](/img/trans.png)
[英]Removing a class after clicking to add same class to a different element with JS
[英]How to add class to an element after js redirect
我想在重定向到主頁后打開模態,但沒有用。
if ($password != $row['user_pwd']) {
echo '<script>
location = "../index.php?error=lwrongPwd&username='.$uidemail.'";
var modal = document.getElementById("myModal");
modal.classList.add("active");
</script>';
exit();
}
這將打開頁面並沒有出現模態。
首先,當您使用 PHP 時,只需通過編寫重定向:
header("Location: yourURLHere");
exit();
除此之外,您需要從目標頁面本身處理該可選類。 主要有兩種方式:
您可以選擇一個選項或將兩者結合起來(例如,用於激活檢查過程的 GET 參數和包含要顯示的所需消息的 SESSION 變量)。 不過,這取決於您和您的需求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.