0

iframe を含むWeb ページ ( http://www.WillenhallPrimary.org/Science.shtml ) があります。iframe には、親 URL とハッシュ (例: http://www.WillenhallPrimary.org/Science.shtml#staff<h2 id="staff">Teachers</h2> ) を使用してジャンプしたいタグが含まれています。また、ジャンプする前にページが読み込まれるまで待ちたいと思います。(簡単なら # の代わりに ? を使用できます。)

iframe は onLoad:javascript を使用してサイズ変更されます (したがって、連続したページのように見えます)。これはうまく機能しますが、これが影響しているかどうかはわかりません。

 function rfs(){
   _i=document.getElementById('ym')
   _i.height=150
   if(typeof _i.contentDocument!=='undefined'){
     _cdd=_i.contentDocument.documentElement
     _i.height=Math.max(_cdd.scrollHeight,_cdd.offsetHeight,_cdd.clientHeight)+25
   }
   else {
     _cdb=_i.contentWindow.document.body
     _i.height=Math.max(_cdb.scrollHeight,_cdb.offsetHeight,_cdb.clientHeight)+25
   }
 }

これは可能ですか?これは簡単に聞こえますが、私は何時間も見ていて、何も機能していません。(私はこれの専門家ではありません。)それを行うより良い方法はありますか?

どんな助けでも大歓迎です。

4

1 に答える 1

0

@mplungjanリダイレクトに感謝​​します-すぐに解決しました。

私が最終的に得たコードは次のとおりです。

window.onload=function(){
  if(window.location.hash!=''){
    document.getElementById('iframe_id').contentWindow.location.hash=window.location.hash
  }
}

うまくいくようです。とても幸せです:-)

于 2016-12-07T09:24:39.680 に答える