私たちは、Web サイトの検索エンジン最適化に多くの時間を費やしてきました。モバイル ユーザーが検索エンジンのいずれかを使用している場合、通常の Web ページを反映したモバイル デザインの Web ページにモバイル ユーザーをリダイレクトしようとしています。サブフォルダー /mobile/ に設定されています。
メインの非モバイル ページでは、変数がキャプチャされます。
<% ThisPage = Request.ServerVariables("URL") %>
<% ThisVAR = "?" & Request.Querystring %>
これらの変数はインクルード ファイルにアクセスして、ユーザーがモバイル ユーザーかどうかを確認し、モバイル ユーザーが検索している可能性のあるページにリダイレクトします。ユーザーがモバイル デバイスを使用していて、検索しているページのモバイル バージョンがない場合は、モバイル フォルダー ルートにリダイレクトする必要があります。
<script type= "text/javascript">
if (screen.width <= 481)
{
if (ThisPage = "/faqs.asp") { document.location = "../mobile/menu_faq.asp" }
else {
if (ThisPage = "/search.asp") { document.location = "../mobile/mobile_search.asp" }
else {
if (ThisPage = "/mte_contacts.asp") { document.location = "../mobile/menu_contacts.asp" }
else {
if (ThisPage = "/mte_history.asp") { document.location = "../mobile/menu_history.asp" }
else {
if (ThisPage = "/mte_locations.asp") { document.location = "../mobile/menu_locations.asp" }
else {
if (ThisPage = "/mte_shipping.asp") { document.location = "../mobile/menu_shipping.asp" }
else {
if (ThisPage = "/shop_discontinued.asp") { document.location = "../mobile/mobile_discontinued.asp" }
else {
if (ThisPage = "/shop_category.asp") { document.location = "../mobile/mobile_category.asp" + ThisVAR }
else {
if (ThisPage = "/shop_commodity.asp") { document.location = "../mobile/mobile_commodity.asp" + ThisVAR }
else { document.location = "../mobile/" }
}
}
}
}
}
}
}
}
}
</script>
私が抱えているjavascript if..elseの問題の解決策を探していましたが、コードにある構文エラーを修正するものが見つかりません。リダイレクトを機能させていますが、正しいモバイル ページに移動せず、正しいロジックを配置できません。どんな助けでも大歓迎です。現在、モバイル デバイスで /mnt_history.asp ファイルに移動することをテストしていますが、/mobile/menu_faq.asp にリダイレクトされます。