求大神帮忙修改js代码,万分感谢!!!!

qq_40873523 2021-05-14 02:34:06
求大神帮忙修改下列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="法律法规" id="select_value">
<input type="text" name="" id="searchPlaceholder" class="import" placeholder="请输入法律法规关键字" onkeydown="keySearch()">
<input type="submit" value="搜 索" class="btn-search" onclick="gosearch()">
</form>
</div>
<script src="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=$(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>
...全文
85 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_40873523 2021-05-14
  • 打赏
  • 举报
回复
怎么写代码?不会写
泡泡鱼_ 2021-05-14
  • 打赏
  • 举报
回复
按你自己说的,你这都做好了第一个。后面两个不就是换一下那个网址吗? 三个网址存一个数组中,先获取当前是哪种搜索(li索引)。然后从数组中取出对应的网址,拼好你的关键词。window.open()

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧