如何在jquery或javascript中使用window.location.replace

哈伦

我有一个已实施实时聊天的网站,当用户单击实时聊天链接时,它将打开一个新窗口。我想做的是,当没有操作员在线时,单击livechat链接时不应打开新窗口,而应在当前打开的选项卡的同一窗口中重定向到网站的“与我们联系”页面,这可能吗?我不知道怎么可能,我试过的是this,它将重定向到此页面,但在新窗口中打开。

window.location.replace('http://mywebsite.com/index.php?route=information/contact');
迈克尔2

问题出在代码周围。您需要在旧窗口中调用该代码。

如果要在聊天窗口中调用它,请尝试:

window.opener.location.replace('http://mywebsite.com/index.php?route=information/contact');
window.close()

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在window.location.replace中使用参数

window.location.replace-POST版本?

window.location.replace奇怪的行为

反应版本的 window.location.replace()?

Javascript window.location.replace只是重新加载了此页面

如何在AngularJS单元测试中模拟$ window.location.replace?

如何使用window.location.href.replace切换href网址中的语言?

是否可以捕获window.location.replace事件?

将变量放置在window.location.replace()内

关于window.location.href.replace的各种可能性

window.location.replace无法正常工作Laravel Ajax

本地存储和 window.location.href.replace

window.location =和window.location.replace()有什么区别?

window.location.assign()和window.location.replace()之间的区别

JavaScript:location.replace在该函数中不起作用

对表格中的数据使用location.replace

如何将查询字符串传递给window.location.replace()?

Phonegap-在我使用window.location.replace离开索引范围后处理推送通知

使用window.location.replace(“ xx”)重定向页面;根据条件

我在使用window.location.replace吗?(我也是在写命令吗?)

Javascript / Jquery window.location

如何在AngularJs的指令中使用$ location

如何在正常功能中使用$ location

使用javascript中的post方法在location.replace中发送数据

如何在 for 循环中使用 Javascript .replace() 方法?

使用document.location.replace重定向后如何记住上一个URL

如何在 React 中使用 Jest 模拟 window.location.href?

如何在window.location.href中使用动态生成的ID?

如果网址包含“#”,则不会触发window.location.replace(document.URL)在最后