gpt4 book ai didi

jquery - 在页面加载时将查询字符串添加到 URL

转载 作者:行者123 更新时间:2023-12-01 08:17:42 25 4
gpt4 key购买 nike

原网址为http://mysite.com/locations.aspx当有人单击某处的“位置”链接并进入此页面时,在页面加载时,我希望按如下方式即时附加 URl?医院是页面上的一个复选框,默认需要选中。因此,当他们登陆页面时,他们会看到所有医院,而不必选中医院复选框并重新加载页面。使用 jquery 可以吗?

http://mysite.com/locations.aspx?k= (“医院”)

Find locations by&#160;<input name="Keyword" type="text" size="70"/><input name="Search" type="submit" value="Search"/><br/><br/>

Hospitals<input name="Hospitals" type="checkbox" value="Hospital"/> &#160;
Offices<input name="Office" type="checkbox" value="Office"/> &#160;
Emergency Centers<input name="EmergencyCenters" type="checkbox" value="Emergency"/>&#160;
Out-Patient Centers<input name="Out-Patient" type="checkbox" value="Out-Patient"/>&#160;
Facilities<input name="Facility" type="checkbox" value="Facility"/>

最佳答案

您可以创建(在页面 http://mysite.com/locations.aspx 内)类似的函数:

function getDefault() {
var trail = '?k=("Hospital")';
var url = "http://mysite.com/locations.aspx" + trail;
window.location = url;
}

并添加 onload<body>标签如

<body onload="getDefault();">

当然,它会重新加载页面(无需用户干预),但会使用新的尾随参数。

...对于复选框,可以添加适当的属性

$(document).ready(function() {
$("input[name=Hospitals]").attr('checked','checked');
}); // ready

并且它将被即时检查。

关于jquery - 在页面加载时将查询字符串添加到 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9437684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com