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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.