只选择链路参数
Select with link parameters only
我试图得到一个下拉链接,但我不想使用链接文件名在url只是参数。
代码如下:
<script type="text/javascript">
function goToNewPage(){
var url = document.getElementById('list').value;
if(url != 'none') {
window.location = url;
}
}
</script>
<select name="list" id="list" accesskey="target">
<option value='none' selected>Choose an item</option>
<option value="?one">item1</option>
<option value="?two">item2</option>
<select>
<input type=button value="Go" onclick="goToNewPage()" />
If I use: <option value="index.html?one">item1</option> it will work but:
我如何让它与它一起工作…这样的:
<option value="?one">item1</option> ?
您可以使用document.location.search
:
function goToNewPage() {
var url = document.getElementById('list').value;
if(url != 'none') {
document.location.search = url;
}
}
如果你的链接文件名是"index.html",那么你应该使用:
<script type="text/javascript">
function goToNewPage(){
var url = document.getElementById('list').value;
if(url != 'none') {
window.location = "index.html" + url;
}
}
</script>
相关文章:
- Facebook共享动态参数链接
- ES6承诺:如何用参数链接函数
- 链路翻转时的 DIV 背景图像交换
- 涡轮链路触发事件链,但随后发生正常导航(Rails 4)
- 如何在反应路由器上的链路中引用状态
- D3.js力导向图保持恒定的链路距离
- 在ui中,路由器用不同的参数链接到相同的状态don'Don’我什么都不做
- 将承诺与多个参数链接在一起
- html<a>将javascript函数与参数链接
- 节点和集群以及使用D3的集群到集群链路
- 链路衰落的奇怪行为
- 手机号码链路检测
- 显示链路去激活的消息
- 增加从节点a到节点b的链路之间的距离
- 只选择链路参数
- 如何切换活动链路
- 如何设置活动链路指示灯位置
- 如何在反应中通过链路路由器获取程序值
- 替换多个链路
- 当存在或不存在路由参数时,启用或禁用链路