选择搜索引擎进行搜索

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>
相关推荐
parafeeee1 天前
程序人生-Hello’s P2P
数据库·后端·asp.net
欲买桂花同载酒5821 天前
程序人生-Hello’s P2P
运维·服务器·数据库
iPadiPhone1 天前
流量洪峰下的数据守护者:InnoDB MVCC 全实现深度解析
java·数据库·mysql·面试
NineData1 天前
AI时代的数据对比:DBA还需要盯着屏幕看差异吗?
运维·数据库
Javatutouhouduan1 天前
SpringBoot整合reids:JSON序列化文件夹操作实录
java·数据库·redis·html·springboot·java编程·java程序员
QWQ___qwq1 天前
Spring Security + MyBatis-Plus 实现自定义数据库用户认证
数据库·spring·mybatis
Filotimo_1 天前
Java后端开发标准流程:从数据库到接口的完整实现
数据库·oracle
泯仲1 天前
从零起步学习MySQL 第一章:初识MySQL及深入理解内部数据类型
数据库·mysql
有想法的py工程师1 天前
PostgreSQL 触发器性能评估实战(pg_stat_user_functions)
数据库·postgresql
雨后的天空@1 天前
Mac 安装多个版本的mysql
mysql