我在哪里可以使用实际替换搜索栏值的输入来尝试我的代码?
Where can I try an my code with an input that actually replaces the search bar value?
我有类似于 Netflix 浏览器搜索功能的代码:
let url = location.href;
localStorage.setItem("url",url);
function modURL() {
if (typeof (history.pushState) != "undefined") {
//get the url
let newURL = localStorage.getItem("url")+'/?q='+document.getElementById('append').value;
let title = document.getElementById('append').value;
let obj = { Title: title, Url: newURL };
console.log("url ", newURL);
history.pushState(obj, obj.Title, obj.Url);
} else {
alert("Browser does not support HTML5.");
}
}
<label>
End URL<input type='text' onInput='modURL()' id='append'>
<label>
我想测试一下它是否真的取代了 URL。我试过 fiddle,日志输出正确的 URL,但是是否有在线编辑器可以让您替换搜索栏?
Stackblitz 做得很好。参见 here
我有类似于 Netflix 浏览器搜索功能的代码:
let url = location.href;
localStorage.setItem("url",url);
function modURL() {
if (typeof (history.pushState) != "undefined") {
//get the url
let newURL = localStorage.getItem("url")+'/?q='+document.getElementById('append').value;
let title = document.getElementById('append').value;
let obj = { Title: title, Url: newURL };
console.log("url ", newURL);
history.pushState(obj, obj.Title, obj.Url);
} else {
alert("Browser does not support HTML5.");
}
}
<label>
End URL<input type='text' onInput='modURL()' id='append'>
<label>
我想测试一下它是否真的取代了 URL。我试过 fiddle,日志输出正确的 URL,但是是否有在线编辑器可以让您替换搜索栏?
Stackblitz 做得很好。参见 here