2012-02-24 105 views
1

原始URL为http://mysite.com/locations.aspx 当某人点击某处的位置链接并进入此页面时,在页面加载时,我希望URl按如下方式附加上?医院是默认情况下需要检查的页面上的复选框。因此,当他们登陆页面时,他们会看到所有的医院,而不必检查医院复选框并重新加载页面。这可能使用jQuery吗?在页面加载时将查询字符串添加到URL

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"/> 
+0

我知道我可以将“位置”链接的HREF值设为http://mysite.com/locations.aspx?k=("Hospital“),并将医院检查为真= ..我想知道是否有任何其他方式? – 2012-02-24 20:43:02

回答

3

您可以创建一个类的函数(页面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 

,它会在飞行中进行检查。

0

在新的浏览器可以使用HTML5 history api更改URL,而不重新加载页面,但是,不支持的话,需要重新加载页面旧版浏览器。

相关问题