我有这个代码:
<form>
<input type="text" placeholder="Enter something..." id="box">
<button onclick="window.open('http://example.com/' + document.getElementById('box').value);">GO
</button>
</form>
当用户输入一个单词并单击“GO”时,他会转到一个网址+输入的值。使用此代码,页面将在新窗口中打开,但我想在同一框架中打开它。我该怎么做?
最佳答案
window.open ('page2.htm','_self',false)
关于javascript - 同框打开URL+元素值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15411246/