更新时间:2022-10-14 19:15:41
我实际上是在没有javascript的情况下发生的。
但是你需要创建一个代理生成css。 / p>
如果下面不是一个可能性,那么所有的赌注似乎都关闭了。祝你好运!
<!DOCTYPE html>
< html lang =en>
< head>
< meta charset =UTF-8>
< title>标题< / title>
< style>
@import url('iframecheck.asp?url = http://www.example.com');
iframe {
width:1000px;
height:400px;
}
< / style>
< / head>
< body>
< iframe src =http://www.example.com>< / iframe>
< / body>
< / html>
iframecheck包含的代码检查url是否有空响应,如果它返回css像这样:
iframe {
display:none;
}
这将自动覆盖其他 iframe
style。
如果你这么做,请不要强制使用text / css内容类型头。
<%response.ContentType =text / css%>
I am trying to make a content area with a specific size, but I want nothing to be displayed if the returned result from the api is empty.
This is the code for the html:
<div class="myclass">
<iframe frameborder="0" src="http://localhost:1000/example"></iframe>
</div>
I'm calling an API that sometimes might return a null result. Javascript is off the table. I've tried to use a css restraint like this:
.myclass {
max-width: 1060px;
max-height: 392px;
& > iframe {
min-height: 0;
min-width: 0;
max-width: 1060px;
max-height: 392px;
}
& > iframe:empty {
display: none;
}
}
The behavior for the css is: the iframe is hidden all the time, although I have content inside it. Also if the iframe is like this:
<div class="myclass">
<iframe frameborder="0" src="http://localhost:1000/example">
<!--notice white-space here-->
</iframe>
</div>
The css will not see the iframe as empty.
I actually made it happen without javascript.
But you need to create a proxy that generates the css.
If below is not a possibility then all bets seem off. Good luck!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
@import url('iframecheck.asp?url=http://www.example.com');
iframe {
width:1000px;
height:400px;
}
</style>
</head>
<body>
<iframe src="http://www.example.com"></iframe>
</body>
</html>
The iframecheck contains code that checks whether the url has empty response, if it does it returns css like this:
iframe {
display:none;
}
Which will automatically override the other iframe
style.
Don forget to force the text/css content type header if you do.
<%response.ContentType="text/css"%>