如果src为空,则隐藏iframe(Hide iframe if src is empty)
我在一个学校系统http://m.rsd17.org/index1.html工作,并正在制作宣布学校取消的公告。 我有一个外部页面,如果出现延迟或学校关闭,我会取消注释并更改文本。 在我的网站顶部,我想隐藏iframe,如果我注释掉外部文件的写入。 这是我使用的一些代码。
我希望它在我没有注释掉外部html中的文本时显示iframe。 我希望iframe完全消失,所以当没有消息显示时,按钮会向上移动。 我已经尝试了一堆不同的jquery脚本,但是当html为空时没有运气去除iframe。 任何想法都会很棒。
I work for a school system http://m.rsd17.org/index1.html and working on an annoucement to show up for school cancellations. I have an external page that I uncomment and change the text if there is a delay or schools closed. On the top of my site I want to hide the iframe if I comment out the writing from the external file. Here is some of the code Im using.
I want it to show the iframe when I haven't commented out the text in the external html. And I want it the iframe totally gone so the buttons move back up when there is no message to display. I've tried a bunch of different jquery scripts, but no luck removing the iframe when the html is empty. Any thoughts would be great.
原文:https://stackoverflow.com/questions/21291502
更新时间:2019-09-05 04:52
最满意答案
您的服务器是否支持PHP? 我问,因为如果这是一个学区,你可能不想假设所有用户都启用了javascript等。最好在后端处理这个问题,用户不依赖于他们的浏览器能力。
在http://f.rsd17.org/frontemergency1.php :
die(); //Comment this out to display a message
?>
Announcement here!
I was able to fix this issue but using SSI, changing the index.html to index.shtml, and moving the file I was using to the correct folder. Changed my links on my main index.shtml. All is better. Thank you FiLeVeR10 for all your help.
相关问答
只是 just
每个人都可以使用网络检查器/控制台查看视频真实网址。 真正保护您的视频免受未经授权人员监视的唯一方法是设置适当的付费墙/身份验证方案。 Everyone will be able to look up the videos real url using the network inspector / console. The only way to really protect your videos from being watched from unauthorised people woul
...
你可以获取src元素,导航到它并获取page_source : from urlparse import urljoin
src = driver.find_element_by_name("iframe_name").get_attribute("src")
url = urljoin(base_url, src)
driver.get(url)
print(driver.page_source)
You can get the src element, navigate to it
...
首先,给iframe一个id :
根据您的评论更新: PHP <?php
$search = "test";
?>
JavaScript的:
var currentSrc = document.getElementById('myIframe').src;
docu
...
所有浏览器内置的安全功能可确保Javascript无法与其他窗口和/或框架中的对象进行交互,前提是这些Windows或框架是从其他站点加载的。 这通常被称为“同源起源政策”。 是否从不同站点加载是由URL的主机名部分决定的。 例如,如果外部框架是从http://yoursite.com加载的,并且内部框架是从http://example.com加载的,那么在外部框架范围内运行的Javascript将无法访问或修改任何属性或内框范围内的对象。 在这种情况下,特定的错误是指示您的Javascript正
...
您的服务器是否支持PHP? 我问,因为如果这是一个学区,你可能不想假设所有用户都启用了javascript等。最好在后端处理这个问题,用户不依赖于他们的浏览器能力。 在http://f.rsd17.org/frontemergency1.php : <?php
die(); //Comment this out to display a message
?>
Announcement here!
I was able to fix this issue but using SSI, changi
...
更新
$(function() {
$('#iframe').load(function() {
if($.trim($(this).contents().find("body").html()) == "") {
$(this).hide();
}
});
});
...
它认为你应该尝试css instade overflow-y: auto;
I think you should try CSS instead overflow-y: auto;
我不是百分百肯定,但我认为你应该能够毫无问题地做到这一点。 由于iframe只是一个框架,因此您应该能够在iframe内部的代码中更改location属性(与其他任何内容相同),并且无论何时生成,该更改都应对父页面可见。 I'm not 100% sure, but I think you should be able to do this without a problem. Since an iframe is just a frame, you should be able to chang
...
调用attr()方法的语法不正确。 第一个参数是属性的名称,第二个参数应该是您要设置的值。 在可能的情况下,也可以使用prop()方法,就像在这种情况下一样。 $('#Stream').prop('src', "https://player.twitch.tv/?channel=" + channel);
$('#Chat').prop('src', "https://www.twitch.tv/" + channel + "/chat?popout=");
attr()方法 prop()方法
...