我想做的是:尝试使用 JavaScript(Mootools) 获取 BASE 元素的 Href,它适用于除 IE8 之外的所有浏览器。
它抛出一个错误:“对象不支持这个属性或方法”
我不知道发生了什么,因为它适用于所有浏览器。
这是我的代码:
var asBaseUrl = document.head.getElement('base');
alert(asBaseUrl.get('href'));
如果有人能帮助我,我将不胜感激。 如果您认为问题不好,请在评论中告诉我。 谢谢。
最佳答案
使用 var asBaseUrl = document.getElement('base');
因为IE8及以下版本不存在document.head,看这里: 它只支持 IE9 或 IE9+ https://developer.mozilla.org/en-US/docs/Web/API/document.head#Browser_compatibility
关于javascript - 尝试在 IE 中使用 Javascript(Mootools) 获取 Base Url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25479722/