当我试图通过rails插入URL时,window.replace方法在js中不起作用
window.replace method not working in js when I try to insert a URL via rails
我有一段javascript来强制浏览器重定向:
window.location.replace("http://google.com")
这很好用——然而,当我尝试通过rails中的模型填充URL时,使用;
window.location.replace("<%= @link.url %>")
它失败了,因为它像CCD_ 1一样将url添加到链接路径的末尾。不知道为什么它不像我手动输入时那样只替换整个URL。有什么想法吗?
注意:我有一个带有url属性的链接模型,这在显示页面上。再往下看javascript @link.url
之外的页面,显示的链接很好。
您需要添加协议:
window.location.replace("http://"+"<%= @link.url %>");
相关文章:
- 在AJAX中使用window.location.replace'成功'回调
- 后退按钮在 window.location.replace(href);之后失败
- window.location.replace.继续重新加载页面,如何停止
- window.location.replace或href时Web会话丢失
- 如何使 window.location.replace 在 IE 9 中工作
- 使用 window.location.replace 但页面仍在浏览器的内存中
- 使用 window.location.href.replace + 单击按钮
- window.location.replace :权限被拒绝和未捕获的异常
- window.location.replace() 在窗体中不起作用
- 如何在window.location.replace.之后保持相同的表单
- 使用window.location.replace重定向不起作用
- window.location.replace不起作用
- window.location.replace在客户端不起作用
- 如果重新加载了同一页,window.location.replace将不起作用
- window.location.replace()无法重定向浏览器
- 'window.location.replace'重定向到给定的页面,但从php破坏会话(仅限Chrom
- 将变量放入window.location.replace()中
- Window.location.replace不能在IE 7上工作
- remote.getGlobal()返回“未定义”;后window.location.replace()
- 在window.location.replace后触发Scroll toTop