选择搜索引擎进行搜索

html 复制代码
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>选择搜索引擎进行搜索</title>
    <script>
        function searchSelectedEngine() {
            var keyword = document.getElementById('keyword').value;
            var engine = document.getElementById('engine').value;
            var encodedKeyword = encodeURIComponent(keyword);

            var searchUrl;

            switch (engine) {
                case 'bing':
                    searchUrl = "https://www.bing.com/search?q=" + encodedKeyword;
                    break;
                case 'baidu':
                    searchUrl = "https://www.baidu.com/s?wd=" + encodedKeyword;
                    break;
                case 'sogou':
                    searchUrl = "https://www.sogou.com/web?query=" + encodedKeyword;
                    break;
                case 'so':
                    searchUrl = "https://www.so.com/s?q=" + encodedKeyword;
                    break;
                default:
                    alert("请选择一个搜索引擎。");
                    return;
            }

            window.open(searchUrl, "_blank");
        }
    </script>
</head>
<body>
    <h1>选择搜索引擎进行搜索</h1>
    <label for="keyword">输入关键词:</label>
    <input type="text" id="keyword" required>
    <label for="engine">选择搜索引擎:</label>
    <select id="engine">
        <option value="bing">Bing</option>
        <option value="baidu">Baidu</option>
        <option value="sogou">Sogou</option>
        <option value="so">So.com</option>
    </select>
    <button onclick="searchSelectedEngine()">搜索</button>
</body>
</html>
相关推荐
寒秋丶13 小时前
Milvus:Json字段详解(十)
数据库·人工智能·python·ai·milvus·向量数据库·rag
ManageEngineITSM17 小时前
技术的秩序:IT资产与配置管理的现代重构
大数据·运维·数据库·重构·工单系统
档案宝档案管理19 小时前
档案宝:企业合同档案管理的“安全保险箱”与“效率加速器”
大数据·数据库·人工智能·安全·档案·档案管理
wangjialelele20 小时前
mysql库操作二
数据库·mysql
星释20 小时前
二级等保实战:MySQL安全加固
android·mysql·安全
Chloeis Syntax20 小时前
MySQL初阶学习日记(1)--- 数据库的基本操作
数据库·学习·mysql
workflower21 小时前
FDD(Feature Driven Development)特征驱动开发
大数据·数据库·驱动开发·需求分析·个人开发
韩立学长21 小时前
基于Springboot的旧物公益捐赠管理系统3726v22v(程序、源码、数据库、调试部署方案及开发环境)系统界面展示及获取方式置于文档末尾,可供参考。
数据库·spring boot·后端
苦学编程的谢1 天前
Redis_4_常见命令(完)+认识数据类型和编码方式
数据库·redis·缓存