为什么在每个浏览器中此代码的行为不同?我应该改变什么来完成所有这些行为中的相同行为?在Firefox它是好的,它使用URL /some/path/?searchedText=sometext
,在IE它当我点击inputButton
,并在Chrome,因为它编码?
这样的失败没有:/some/path/%3FsearchedText=sometext
代替/some/path/?searchedText=sometext
独立于浏览器的javascript
HTML
<input id="inputText" type="text" class="form-control" placeholder="Searched text"> <input id="inputButton" type='button' value='Search' class="btn" onclick="myFunction()"/>
的JavaScript
function myFunction() {
var text = document.getElementById('inputText').value;
var location = "some/path/?searchedText=";
window.location.pathname = location + text;
}
什么版本的IE? – 2016-12-04 10:09:21
这是最新的版本11。 –