0

私は自分のドメインと joomla で iframe をホストしています! iframe ラッパーをセットアップしました。私が最初に与えたURLhttp://www.と私の設定は次のとおりです。

scroll bars: auto
width: 100%
height: 500

auto height: yes
auto add: no

両方のブラウザーで javascript エラー (null はオブジェクトではありません) が表示されます: Safari、Firefox、および Chrome を使用しています。このエラーは、joomla コアのスクリプトを指しています。

<script type="text/javascript">
function iFrameHeight() {
    var h = 0;
    if (!document.all) {
        h = document.getElementById('blockrandom').contentDocument.height;
        document.getElementById('blockrandom').style.height = h + 60 + 'px';
    } else if (document.all) {
        h = document.frames('blockrandom').document.body.scrollHeight;
        document.all.blockrandom.style.height = h + 20 + 'px';
    }
}
</script>

これにより、ラッパーが 500px の高さに保たれ、iframe の高さに応じて自動的に追加されます。

この関数を何に置き換えることができますか? 前もって感謝します、ローラン。

4

3 に答える 3

0

iframeのサイズを変更するには、これを試してください。iframeを含むすべての要素で、高さが100%に設定されている必要があります。

<script type="text/javascript">
$(document).ready(function() {
   function iSize(){
document.getElementById('mainFrame').height = document.getElementById('mainFrame').contentWindow.document.body.scrollHeight;
document.getElementById('mainFrame').height = document.getElementById('mainFrame').contentDocument.documentElement.scrollHeight;
   }
});
</script>
  1. ファイルcomponents/com_wrapper/views/wrapper/tmpl/default.phpをtemplates/your_template / html / com_wrapper/wrapper/にコピーします
  2. ファイルtemplates/your_template / html / com_wrapper /wrapper/default.phpを開きます
  3. 関数iFrameHeight()を以下の新しい関数に置き換えます。
function pageY(elem) {
        return elem.offsetParent ? (elem.offsetTop + pageY(elem.offsetParent)) : elem.offsetTop;
    }
    var buffer = 0; //scroll bar buffer
    function iFrameHeight() {
        var height = document.documentElement.clientHeight;
        height -= pageY(document.getElementById('blockrandom'))+ buffer ;
        height = (height < 0) ? 0 : height;
        document.getElementById('blockrandom').style.height = height + 'px';
    }
    document.getElementById('blockrandom').onload=iFrameHeight;
    window.onresize = iFrameHeight;
于 2013-01-30T19:32:15.933 に答える
0

このコードは私には機能しません。しかし、私はそれを解決しました:

var the_height = document.getElementById('blockrandom').contentWindow.document.body.scrollHeight;
document.getElementById('blockrandom').style.height = the_height; //height + 'px'; 
于 2014-06-12T09:06:04.393 に答える
0

申し訳ありませんが、正しい行: var the_height=document.getElementById('blockrandom').contentWindow.document.body.scrollHeight; document.getElementById('blockrandom').height = the_height;

バージョン ps: 1.6 バージョン joomla: 3.2.1

于 2014-06-12T09:09:44.210 に答える