当我通过一些 URL 查询从另一个页面重定向到 index.php
时,我需要调用 index.php
中的 javascript 函数。
这是我的实际网址:index.php?id=10&func=view
。我需要使用此 URL 唤醒 index.php
中的 JavaScript 函数。
最佳答案
您可以在 php 代码中设置 session 变量
$_SESSION["jsload"] = "1";
然后检查index.php中是否设置了该变量
<?php
if ( isset($_SESSION['jsload'])=="1" ) { ?>
//javascript here
<?php
}
?>
确保在两个页面上都使用 session_start()
函数
并取消设置并销毁使用过的 session
关于javascript - 重定向时通过其他页面上的 url 调用 javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43449290/