![](/img/trans.png)
[英]jQuery - Change Iframe height in the onclick event of a button inside the iframe
[英]why can't change iframe height from jquery inside iframe?
我在下面的代碼中遇到了iframe問題。 當我重新加載瀏覽器時,iframe的高度仍為100px。 我想將iframe高度更改為500px。
<iframe style="height:100px" width="100%" id="parentiframe">
<head><script src="/mobile/themes/2015/js/jquery-2.1.3.min.js"></script>
<script>
$(document).ready(function(){
$("#parentiframe").css({"height":"500px"});
});
</script>
</iframe>
我嘗試那樣,但是不起作用。 如何將parentiframe更改為500px?
嘗試
<iframe style="height:100px" width="100%" id="parentiframe">
<head><script src="/mobile/themes/2015/js/jquery-2.1.3.min.js"></script>
<script>
$(document).ready(function(){
$("#parentiframe", window.parent.document).css({"height":"500px"});
});
</script>
</iframe>
當然,兩個文檔都應具有相同的域,否則由於安全問題將無法使用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.