求大神幫忙修改下列js代碼,要實作的功能是:
選擇串列中的li1要實作
http://search.chinalaw.gov.cn/SearchLawTitle?effectLevel=&SiteID=124&Query="輸入的關鍵詞"
的搜索
選擇串列中的li2要實作
http://std.samr.gov.cn/search/std?q="輸入的關鍵詞"
的搜索
選擇串列中的li3要實作
http://www.sxpc.gov.cn/sxsrdsearch/search.jsp?sword="輸入的關鍵詞"
的搜索
現在第一個搜索可以做到,怎么實作第二、第三個搜索。
<!DOCTYPE html>
<!-- saved from url=(0030)http://www.shanxi.gov.cn/sozc/ -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<div class="select_box">
<span class="select_txt">法律法規</span>
<span class="select-icon"></span>
<ul id="list" class="option">
<li ID="l1">法律法規</li>
<li ID="l2">行業標準</li>
<li ID="l3">地方法規</li>
</ul>
</div>
<form action="" >
<input type="hidden" name="" value="https://bbs.csdn.net/topics/法律法規" id="select_value">
<input type="text" name="" id="searchPlaceholder" class="import" placeholder="請輸入法律法規關鍵字" onkeydown="keySearch()">
<input type="submit" value="https://bbs.csdn.net/topics/搜 索" class="btn-search" onclick="gosearch()">
</form>
</div>
<script src="https://bbs.csdn.net/topics/js/jquery.min.js"></script>
<script>
$(function(){
$(".select_box").click(function(event){
event.stopPropagation();
$(this).find(".option").toggle();
$(this).parent().siblings().find(".option").hide();
});
$(document).click(function(event){
var eo=$(event.target);
if($(".select_box").is(":visible") && eo.attr("class")!="option" && !eo.parent(".option").length)
$('.option').hide();
});
$(".option li").click(function(){
var check_value=https://bbs.csdn.net/topics/$(this).text();
var zlValue = $('.option li:eq(1)').html();
var bqValue = $('.option li:eq(2)').html();
var searchPlaceholder = document.getElementById("searchPlaceholder").value;
$(this).parent().siblings(".select_txt").text(check_value);
$("#select_value").val(check_value);
if(check_value == zlValue) {
$('#searchPlaceholder').prop('placeholder','請輸入行業標準關鍵字');
}else if(check_value == bqValue) {
$('#searchPlaceholder').prop('placeholder','請輸入地方法規關鍵字');
}else {
$('#searchPlaceholder').prop('placeholder','請輸入法律法規關鍵字');
}
});
})
</script>
<script>
$(function () {
// ie兼容策略
if (typeof String.prototype.startsWith !== 'function') {
String.prototype.startsWith = function(prefix) {
return this.slice(0, prefix.length) === prefix;
};
}
if (typeof String.prototype.endsWith !== 'function') {
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
}
})
function tabclick(db) {
var url = "?tab=" + db + "&siteCode=14000000450";
location.href = url;
}
function outsite(url) {
window.open(url, "_blank")
}
function gosearch() {
var qt = document.getElementById("qt").value;
if (qt == null || qt == "") {
alert("請輸入要搜索的關鍵字");
} else {
var url = "http://search.chinalaw.gov.cn/SearchLawTitle?effectLevel=&SiteID=124&Query=" + encodeURIComponent(qt);
window.open(url, "_blank")
}
}
function hot(word) {
var url = "s?tab=all&siteCode=14000000450&qt=" + encodeURIComponent(word);
window.open(getHref() + url, "_self")
}
function keySearch() {
var evt = window.event || e;
if (evt.keyCode == 13) {
gosearch()
}
}
function getHref() {
var href = location.href;
if (href.indexOf('?') != -1){
href = href.substring(0, href.lastIndexOf('?'))
}
if (!href.endsWith('/')){
href += '/'
}
return href;
}
$(function () {
// ie兼容策略
if (typeof String.prototype.startsWith !== 'function') {
String.prototype.startsWith = function(prefix) {
return this.slice(0, prefix.length) === prefix;
};
}
if (typeof String.prototype.endsWith !== 'function') {
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
}
})
</script>
</body></html>
uj5u.com熱心網友回復:
按你自己說的,你這都做好了第一個。后面兩個不就是換一下那個網址嗎?三個網址存一個陣列中,先獲取當前是哪種搜索(li索引)。然后從陣列中取出對應的網址,拼好你的關鍵詞。window.open()
uj5u.com熱心網友回復:
怎么寫代碼?不會寫轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/284056.html
標籤:JavaScript