根据网址隐藏div

编程入门 行业动态 更新时间:2024-10-13 20:15:20
本文介绍了根据网址隐藏div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

很抱歉,如果这是另一个转发。我一直在试图找到一个解决方案,但没有任何工作,我已经尝试过。我正在使用一个博客,我有完整的HTML控制。我通常可以找到基本html的方法,但是对于Java或CSS,我是一个完整的newb。对不起,我什么也不知道。

Sorry if this is another repost. I have been attempting to find a solution but nothing works that I have tried. I am using a blog which I have full html control over. I can usually find my way around basic html but when it comes to Java or CSS I am a complete newb. Sorry, I know absolutely nothing.

既然这样,我有两个边栏div,我试图隐藏在一个特定的网址,以利用更多的空间用于内容iframe。这是我尝试使用的编码之一,似乎没有工作,或者我失去了一些东西。

Now that that is out of the way. I have two sidebar div's that I am trying to hide on one specific url to utilize more space for a content iframe. This is one of the coded I have tried to use which doesn't seem to work or I am missing something.

<!DOCTYPE HTML PUBLIC - // W3C // DTD HTML 4.01 Transitional // EN www.w3/TR/html4/loose.dtd\"> < html> < head> < script language =text / javascript<?php &#36;(function(){ if(window.location.search === mywebsite / Videos.html){&#36;('#navleft')。hide(); } else {&#36;('#navleft' ).show(); } }); ?> < / script>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3/TR/html4/loose.dtd"> <html> <head> <script language="text/javascript" <?php &#36;(function(){ if (window.location.search === "mywebsite/Videos.html") { &#36;('#navleft').hide(); } else { &#36;('#navleft').show(); } }); ?> </script>

请记住,当涉及到php或java时,我什么都不知道。我想为#navright和#navleft这样做。这也在CSS部分。感谢您的帮助!!

Please remember I do not know anything when it comes to php or java. I want to do this for both #navright and #navleft. Also this is in the CSS section. Thanks for any help!!

#navright{ width: 200px; } #navleft{ width: 200px; } #content{ margin:0px; }

推荐答案

看起来你正在使用jQuery,你需要包括浏览器的jQuery javascript文件来理解语法。

It looks like you are using jQuery, you need to include the jQuery javascript file for the browser to understand the syntax.

docs.jquery/Downloading_jQuery

另外,删除<?php 和?> 标记并将&#36; 更改为 $ :

Also, remove the <?php and ?> tags and change &#36; to $:

如果您尝试获取当前网址, window.location.search 应改为 window.location.pathname

And if you are trying to get the current URL, window.location.search should be changed to window.location.pathname

developer.mozilla/zh/DOM/window.location

<script language="text/javascript"> $(function(){ if (window.location.pathname == "mywebsite/Videos.html") { $('#navleft').hide(); } else { $('#navleft').show(); } }); </script>

更多推荐

根据网址隐藏div

本文发布于:2023-10-31 13:30:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1546225.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网址   div

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!