Reputation: 11276
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);
}
Upvotes: 0
Views: 3250
Reputation: 120526
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.
Upvotes: 2
Reputation: 5086
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
Upvotes: 1
Reputation: 13727
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
.
Upvotes: 2