选择搜索引擎进行搜索

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>
相关推荐
dfdfadffa11 小时前
如何用模块化方案组织一个可扩展的前端组件库项目
jvm·数据库·python
2301_8125396711 小时前
SQL中如何高效实现分组数据的批量更新_利用窗口函数与JOIN
jvm·数据库·python
2501_9012005311 小时前
如何实现SQL存储过程存储过程参数标准化_统一命名规范
jvm·数据库·python
运气好好的12 小时前
Golang怎么用embed嵌入SQL文件_Golang如何将SQL迁移文件嵌入Go程序统一管理【技巧】
jvm·数据库·python
Elastic 中国社区官方博客12 小时前
在 Elasticsearch 中使用原生 PromQL 支持查询 Prometheus 指标
大数据·elasticsearch·搜索引擎·信息可视化·全文检索·prometheus
念何架构之路12 小时前
MySql常见ORM
数据库·mysql
平凡码工人13 小时前
navicat 17 lite 安装教程
mysql
喜欢流萤吖~13 小时前
Elasticsearch集群:高可用与水平扩展的基石
大数据·elasticsearch·搜索引擎
xcLeigh13 小时前
KES数据库安全、权限、审计实战
数据库·安全·备份·权限·审计·ssl加密·密码策略
zjy2777713 小时前
c++如何实现日志文件的异步落盘功能_基于无锁队列方案【附代码】
jvm·数据库·python