选择搜索引擎进行搜索

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>
相关推荐
qq_3564086634 分钟前
es通过分片迁移迁移解决磁盘不均匀问题
java·数据库·elasticsearch
h_k100861 小时前
当GitHub宕机时,我们如何协作?
大数据·elasticsearch·搜索引擎
武子康1 小时前
Java-122 深入浅出 MySQL CAP理论详解与分布式事务实践:从2PC到3PC与XA模式
java·大数据·数据库·分布式·mysql·性能优化·系统架构
爱考证的小刘1 小时前
阿里云ACA认证[特殊字符]阿里云ACP认证
数据库·阿里云·云计算
Databend1 小时前
基于 Databend 的实时数据汇聚平台建设
数据库
玄尺_0072 小时前
bug:uniCloud报Business Failed, 参数有误retry invoke error
数据库·bug
@CLoudbays_Martin112 小时前
CDN是否能有效检测并且同时防御Ddos 和 CC 攻击?
java·服务器·网络·数据库·git·数据库开发·时序数据库
爱喝水的鱼丶2 小时前
SAP-MM:SAP采购组织全面学习指南:从概念到实战配置图解
运维·开发语言·数据库·学习·sap·mm模块·采购组织
深鱼~3 小时前
DbGate数据库管理新方案:cpolar打造跨平台远程访问通道
数据库
WAWA战士3 小时前
mysql总结
数据库