如何在Lynx中查看我的网页时隐藏div?

时间:2022-03-24 10:34:42

My website has a div element (in form of a block) that I want to make invisible whenever a user visits the website through a text based browser like Lynx, that doesn't support JavaScript.

我的网站有一个div元素(以块的形式),当用户通过像Lynx这样不支持JavaScript的基于文本的浏览器访问网站时,我希望它不可见。

Basically what command or code do I need to write in order for this to happen?

基本上我需要编写什么命令或代码才能实现此目的?

2 个解决方案

#1


3  

Since you can't run javascript there, you have to not send that div in the first place for it to be invisible in the text-mode browser.

由于您无法在那里运行javascript,因此您必须首先不发送该div,因为它在文本模式浏览器中不可见。

You can make a server side user-agent check and do not render that div. Lynx user agents: http://www.useragentstring.com/pages/Lynx/

您可以进行服务器端用户代理检查,不要呈现该div。 Lynx用户代理:http://www.useragentstring.com/pages/Ly​​nx/

#2


1  

You can set the div invisible by default.
and make it visible in your js code.
Thus it'd not appear on a text-mode browser.

您可以默认将div设置为不可见。并使其在您的js代码中可见。因此它不会出现在文本模式浏览器上。

#1


3  

Since you can't run javascript there, you have to not send that div in the first place for it to be invisible in the text-mode browser.

由于您无法在那里运行javascript,因此您必须首先不发送该div,因为它在文本模式浏览器中不可见。

You can make a server side user-agent check and do not render that div. Lynx user agents: http://www.useragentstring.com/pages/Lynx/

您可以进行服务器端用户代理检查,不要呈现该div。 Lynx用户代理:http://www.useragentstring.com/pages/Ly​​nx/

#2


1  

You can set the div invisible by default.
and make it visible in your js code.
Thus it'd not appear on a text-mode browser.

您可以默认将div设置为不可见。并使其在您的js代码中可见。因此它不会出现在文本模式浏览器上。