0

I have a web page (http://www.WillenhallPrimary.org/Science.shtml) which contains an iframe. The iframe includes an <h2 id="staff">Teachers</h2> tag which I'd like to jump to using the parent URL and a hash e.g. http://www.WillenhallPrimary.org/Science.shtml#staff. I'd also like to wait until the page loads before jumping. (I can use a ? instead of # if that's easier.)

The iframe is resized using onLoad:javascript (so it looks like a contiguous page) which works nicely but I don't know if this is affecting it.

 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
   }
 }

Is this possible? This sounds simple but I've spent hours looking and nothing's working. (I'm not an expert at this.) Is there a better way of doing it?

Any help greatly appreciated.

mplungjan
  • 169,008
  • 28
  • 173
  • 236

1 Answers1

0

@mplungjan thanks for the redirect - that solved it straight away.

The code I ended up with is:

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

seems to work ok. Very happy :-)