add search nothing to offical page

master
IoTcat 5 years ago
parent 2e6c919896
commit ee2c9d85b6
  1. 18
      server/cn/home/www/HomePage/index.html

@ -28,29 +28,29 @@
function do_baidu_search() { function do_baidu_search() {
var search_txt = document.getElementById("search-bar-input").value; var search_txt = document.getElementById("search-bar-input").value;
if (search_txt == "") { if (search_txt == "") {
alert("search text is empty ! "); window.open("https://www.baidu.com");
return false; return;
} }
var search_url = "https://www.baidu.com/s?wd=" + search_txt; var search_url = "https://www.baidu.com/s?wd=" + encodeURI(search_txt);
window.open(search_url); window.open(search_url);
} }
function do_google_search() { function do_google_search() {
var search_txt = document.getElementById("search-bar-input").value; var search_txt = document.getElementById("search-bar-input").value;
if (search_txt == "") { if (search_txt == "") {
alert("search text is empty ! "); window.open("https://www.google.com");
return false; return;
} }
var search_url = "https://www.google.com/search?newwindow=1&hl=zh-CN&q=" + search_txt; var search_url = "https://www.google.com/search?newwindow=1&hl=zh-CN&q=" + encodeURI(search_txt);
window.open(search_url); window.open(search_url);
} }
function on_enter_key(){ function on_enter_key(){
if (event.keyCode==13){ if (event.keyCode==13){
var search_txt = document.getElementById("search-bar-input").value; var search_txt = document.getElementById("search-bar-input").value;
if (search_txt == "") { if (search_txt == "") {
alert("search text is empty ! "); window.open("https://www.google.com");
return false; return;
} }
var search_url = "https://www.google.com/search?newwindow=1&hl=zh-CN&q=" + search_txt; var search_url = "https://www.google.com/search?newwindow=1&hl=zh-CN&q=" + encodeURI(search_txt);
window.open(search_url); window.open(search_url);
} }
} }

Loading…
Cancel
Save