简体   繁体   English

禁用JavaScript:如何在移动设备和台式机上显示不同的消息。

[英]JavaScript disabled: how to show different messages for mobile and desktop.

I need to display different messages for desktop and mobile web sites when JavaScript is disabled. 禁用JavaScript时,我需要为台式机和移动网站显示不同的消息。

Currently I have 目前我有

<noscript>  
    <meta http-equiv="Refresh" content="0; URL=/error.html" />
</noscript>

and i need code that would do (i use pseudocode) 而且我需要可以做到的代码(我使用伪代码)

<noscript>
    if desktop
    <meta http-equiv="Refresh" content="0; URL=/error.html" />
    if mobile
    <meta http-equiv="Refresh" content="0; URL=/mobile-error.html" />
</noscript>

Thanks 谢谢

Is there any server backend to your website? 您的网站是否有服务器后端? You could try and do mobile browser detection based off of the user-agent received from the connecting browser. 您可以尝试根据从连接浏览器接收到的用户代理进行移动浏览器检测。

See this stackoverflow post about using the user agent to detect mobile. 请参阅有关使用用户代理检测移动设备的stackoverflow帖子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何插入对移动设备禁用并且仅在台式机上可用的JavaScript代码? - how to insert javascript code that is disabled for mobile devices and only works on desktop? 怎么做 <iframe> 在wordpress中响应。 我只能在移动设备或桌面设备上做出响应。 需要它在两者中都运作良好 - how to make <iframe> responsive in wordpress. I can only make it responsive in either mobile or in desktop. need it to work well in both 如何在JavaScript中为台式机和移动设备创建不同的onclick行为? - How to create different onclick behavior for desktop and mobile in javascript? 移动JavaScript是否与台式机JavaScript不同? - Is mobile JavaScript different from desktop JavaScript? 如果选择了不同的选项,如何显示不同的消息(不弹出)。 使用Javascript - How to show different messages (not popup) if different options selected. Javascript 如何仅在移动设备上显示桌面版本 - Blogger - How to only show desktop version on mobile - Blogger 在桌面上显示移动导航 - Show mobile nav on desktop 如何获取JavaScript在桌面而不是移动设备上运行功能 - How to get javascript to run a function on desktop but not on mobile 手机/台式机的不同菜单 - Different menus for mobile/desktop 桌面和移动的不同脚本 - Different scripts for Desktop and Mobile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM