html
<p id="searchText">Search for "Hello, world!" on Bing.</p>
<a href="#" onclick="searchOnBing()">Search</a>
js
function searchOnBing() {
let searchText = document.getElementById("searchText").textContent;
let encodedText = encodeURIComponent(searchText);
// 构造 BING 搜索 URL 并跳转
let url = "https://www.bing.com/search?q=" + encodedText;
window.location.href = url;
}
转载
HTML跳转搜索指定字符串 - P6OY
https://blog.p6oy.top/2023/03/25/5.html