用JS实现站内搜索

用JS实现站内搜索

html代码

		<form action="https://fsoufsou.com/search" id="searchForm">
				<input placeholder="在Fsou中搜索本站资源" class="fsoustxt" type="text" name="q" value="" required>
				<input type="hidden" name="site" value="你的域名">
				<input type="submit" value="站内搜索" class="fsoubutton">
			</form>

JS代码

		<script>
			var searchForm = document.getElementById('searchForm');
			searchForm.onsubmit = function(){
				var url = this.action;
				var q = this.children['q'].value;
				var site = this.children['site'].value;
				var url = url + '?q='+q+' site:'+ site;
				window.open(url);
				return false;
			};
		</script>

CSS需要自己写这里就不班门弄斧了


然后就是…希望Fsou尽快实现全网开放吧。

1 Like