javascript - window.location in IE base href

标签 javascript internet-explorer relative-path

我在使用 Internet Explorer 和 window.location 时遇到问题。

我正在为我的后端项目使用 Backbone.js。

基本 URL 是“http://www.domain.com/admin/” '

我的 js 函数看起来像:

openFolder : function(e) {
        var folder_id = '4';
        window.location = "controller/folder/" + folder_id;
    },

因此,当我在“www.domain.com/admin/controller”页面上单击按钮打开文件夹时,它在所有浏览器上都能正常工作,但 Internet Explorer 会将我重定向到 ' http://www.domain.com/admin/controller/controller/folder/4 '

你能帮我解决这个问题吗?

谢谢 宜兰

最佳答案

location.href = location.origin + "/controller/folder/" + folder_id;

关于javascript - window.location in IE base href,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18975430/

相关文章:

javascript - 在 Angular 6 中使用脚本 - recaptcha

javascript - 在 ASP.NET MVC 中使用路由 URL 构建导航

javascript - react : TypeError: Cannot read property 'value' of undefined

html - 当源文件位于其他目录中时,gcovr 不会创建详细报告

javascript - 鼠标悬停时获取正确的 x 和 y 坐标

javascript - 单选按钮上的 onchange 在 IE8 中无法正常工作

javascript - 阐明 IE 中的 clearTimeout 行为

java - Dos命令获取IE页面源

jquery - 使用 jQuery 将具有相对路径的外部 HTML 页面加载到 DIV 中

html - 背景图像不适用于 css id 但适用于 css body