选择搜索引擎进行搜索

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>
相关推荐
Microsoft Word10 分钟前
数据库系统原理(第一章 数据库概述)
数据库·oracle
华为云开源20 分钟前
openGemini 社区人才培养计划:助力成长,培养新一代云原生数据库人才
数据库·云原生·开源
kejijianwen3 小时前
JdbcTemplate常用方法一览AG网页参数绑定与数据寻址实操
服务器·数据库·oracle
编程零零七4 小时前
Python数据分析工具(三):pymssql的用法
开发语言·前端·数据库·python·oracle·数据分析·pymssql
高兴就好(石6 小时前
DB-GPT部署和试用
数据库·gpt
这孩子叫逆7 小时前
6. 什么是MySQL的事务?如何在Java中使用Connection接口管理事务?
数据库·mysql
Karoku0667 小时前
【网站架构部署与优化】web服务与http协议
linux·运维·服务器·数据库·http·架构
码农郁郁久居人下7 小时前
Redis的配置与优化
数据库·redis·缓存
MuseLss8 小时前
Mycat搭建分库分表
数据库·mycat
Hsu_kk9 小时前
Redis 主从复制配置教程
数据库·redis·缓存