Jump to content

Target frame within frame.


GB_001

Recommended Posts

I tried targeting my AJAX to the parent document from a frame with this part of my AJAX function:

 

ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){

var ajaxDisplay = document.parent.getElementById('divvy');
ajaxDisplay.innerHTML = ajaxRequest.responseText;
}

 

But it didn't work.

What I know from my problem is that I'm targeting wrong.

Can someone tell me what is the right way to target the parent frame?

 

Thanks.

-GB

Link to comment
https://forums.phpfreaks.com/topic/94599-target-frame-within-frame/
Share on other sites

if the document is in a frame, then wouldn't the parent document be the top? (unless it is a nested frame) That doc would just be a frameset doc, so your innerHTML would not be valid

 

I'm not sure document.parent is valid, it should be window.parent  .It is best to leave it off because that is more cross browser compatable

 

if you are calling one frame from another then it is best to just start from the top and go down:

var ajaxDisplay = top.someframename.getElementById('divvy');

 

--the document in the frame targetted must be from the same domain as the calling document or it will not work - browsers stop it as a security violation

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.