3

i am doing an iframe request to a page on my backend server. the page does a redirect and returns the same url as that which is requested but also appends a query string. how can i get the returned url and query string? my ajax class looks like this:

var ajax =
{
  send: function(urlstring)
  {
    if(!this.ifram)
    {
     this.ifram = document.createElement('iframe');
     this.ifram.style.display = 'none';
     if(this.ifram.addEventListener) this.ifram.addEventListener('load',ajax.receive,false);
     else if(this.ifram.attachEvent) this.ifram.attachEvent('onload',ajax.receive);
     document.body.appendChild(this.ifram);
    }
    this.ifram.setAttribute('src',urlstring);
  },
  receive: function()
  {
     content = ajax.ifram.contentWindow.document.body.innerHTML;
     returnurl = ajax.ifram.src;
     alert('return url: '+returnurl);
  }
};

however returnurl always holds the original urlstring value even if the response is different.

cheers peter

mulllhausen
  • 4,225
  • 7
  • 49
  • 71
  • as per [this other question](http://stackoverflow.com/questions/938180/get-current-url-from-iframe) i think `returnurl = ajax.ifram.contentWindow.location.href` should do it. will check when i get home in a few hours... – mulllhausen Jul 02 '11 at 06:35

1 Answers1

2

returnurl = ajax.ifram.contentWindow.location.href does the trick :)

mulllhausen
  • 4,225
  • 7
  • 49
  • 71