0

The problem is I'm using an iframe to process a login form via POST over https, but the parent hosting the iframe is http (although in the same domain)

is this doable?

I can't test this quite yet because I can only use https in our staging environment.

Thanks

  function process_form(f){


    var l = $("iframe#loginFrame");    
    if(l.length==0){      
      f.attr("target","loginFrame");      
      $('<iframe src="/player.htm?ajax=1"'+(!_DBG?' class="hide"':'')+' id="loginFrame" name="loginFrame"></iframe>').prependTo('body');      
      $("iframe#loginFrame").load(function() {
        var u = this.contentWindow.location;


        if(String(u).indexOf("confirm")>=0){ 
          change_form(1);
        }else if(u!=this.src){
          change_form(0);
        }
        log(u);
        log(this.src);

      });



    }else{
      warn("Frame already exists!"); 
    }

    change_form(-1);
    setTimeout(function(){ f.submit();},500);
    log(f);
  }
qodeninja
  • 10,946
  • 30
  • 98
  • 152

3 Answers3

2

Is document.getElementById('iframename').src what you're looking for?

EDIT

It appears that this has been previously answered. Try document.getElementById("iframename").documentWindow.location.href.

Community
  • 1
  • 1
Jon Onstott
  • 13,499
  • 16
  • 80
  • 133
2

Short answer, yes. To access the location of an iframe, btw, use myIframe.contentWindow.location. See http://www-archive.mozilla.org/docs/dom/domref/dom_frame_ref16.html for details.

Two frames in different protocols (http vs https) are in different origins, so you can't do anything that requires same-origin privileges.

From http://en.wikipedia.org/wiki/Same_origin_policy#Origin_determination_rules

The term "origin" is defined using the domain name, application layer protocol, and (in most browsers) TCP port of the HTML document running the script.

But the location should be accessible regardless of same-origin policy.

Mike Samuel
  • 118,113
  • 30
  • 216
  • 245
1

you might be able to in your child frame call the parent so when the child frame loads you could do

domReady{ parent.form.hiddenField.value = document.location.href }

basically you pass from child back to parent. You'll have to experiment if the child can call a method in the parent which you might be able to do and pass the location to that method

dstarh
  • 4,976
  • 5
  • 36
  • 68