javascript - 如何从其他页面从 google 帐户退出?
问题描述
我已经成功地向我的网站暗示了 Google 登录,并且只要它们都在同一页面上,Signout 就可以正常工作。我在网站上有一个导航栏,它包含在每个页面(包括登录页面)的顶部,我想在导航栏上找到退出按钮,但是当我这样做时,它不再起作用了。因为我使用的是 PHP,所以我尝试设置header('location:login.php');
登录和注销按钮所在的位置,然后使用
它并没有用,我还尝试在用户使用后<script src="'.$js.'script.js"></script> // this is my js script where the signOut() function is declared <script type="text/javascript"> window.onload = signOut; </script>
触发注销按钮document.getElementById("google_signout").click;
用 php punction 发送到那里,header('location:login.php');
它也没有工作。什么是正确的方法?顺便说一句,我在 PHP 代码中编写 Javascript 代码,就像这样:
<?php
if (isset($_SESSION['User'])){ // run this if the user is logged in
echo '<script src="'.$js.'script.js"></script> //load my script where the google signOut() is declared
<script type="text/javascript">
window.onload = signOut;
</script>';
}else{
//do something else
}
?>
解决方案
推荐阅读
- android - Android Studio UI 文本(如文件名、选项等)在 MAC 中很小
- pandas - 如何通过在熊猫中添加或减去两个时间列来创建新列
- azure - 使用 UseDevelopmentStorage = true 运行时 Azure 函数抛出错误
- excel - 这是 Microsoft Excel 的数据可视化和数据操作问题
- python-3.x - 通过 Python3 调用 ThingsBoard REST API
- error-handling - caseMatch 测试不起作用:只有一列
- powershell - 更改现有脚本中的 DNS 查找
- python - ValueError: 为 '{{node max_pooling2d_16/MaxPool}} 从 1 中减去 2 导致的负维度大小
- powerbi - Power BI 报表与 Razor Pages 的集成
- python - 在Tensorflow中使用model_zoo的faster_rcnn_resnet101_v1_640x640_coco17_tpu-8时遇到错误==2.5