我有一個非常簡單的網頁:
<html>
<head>
<meta http-equiv="Refresh" content="0; url='https://www.website1.com'" />
</head>
<body>
</body>
</html>
而不是這總是重定向到同一個網站,我想根據用戶是在移動設備上還是在他們的計算機上使用瀏覽器來重定向到 website1 或 website2。我是前端 Web 開發的新手,因此非常感謝您提供的任何幫助。
謝謝!
uj5u.com熱心網友回復:
您應該為此使用 Javascript。根據 檢測設備型別userAgent,然后重定向到新網站
<script>
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// redirects if mobile
window.location('https://example.com')
} else {
// redirects if whatever else
window.location('https://example2.com')
}
</script>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/454948.html
標籤:html 网络前端 http-equiv
