Error: Permission denied for sitename to get property Location.href from sitename.
I have an iframe in a webpage. This iframe has Click here to register link that redirects to the new window webpage. I am getting the above error when click here is clicked.
Please help in this issue.
<a href="javascript:openEventReg()" is called when click here is selected
<script>
function openEventReg()
{
username=document.getElementById('username').value;
var id = gup( 'id' );
var eventname;
return ("/registration/eventregister.php?event=testing&uname="+username);
}
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( parent.location.href );
if( results == null )
return "";
else
return results[1];
}
</script>
-
1: What line is returning the error? 2: Why not use a form element? (You can style submit buttons to look like links.)Anonymous– Anonymous2010年01月27日 06:15:57 +00:00Commented Jan 27, 2010 at 6:15
-
1Looks that the parent page is on another domain... en.wikipedia.org/wiki/Same_origin_policyChristian C. Salvadó– Christian C. Salvadó2010年01月27日 06:17:32 +00:00Commented Jan 27, 2010 at 6:17
2 Answers 2
This is the intended behaviour in modern browsers. Frames are not allowed to access their parents in any way unless they reside on the same domain. This is done in an attempt to prevent cross-site scripting attacks.
Comments
put your redirect function in your main html. On click just call parent.funcName().