0

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>
2
  • 1: What line is returning the error? 2: Why not use a form element? (You can style submit buttons to look like links.) Commented Jan 27, 2010 at 6:15
  • 1
    Looks that the parent page is on another domain... en.wikipedia.org/wiki/Same_origin_policy Commented Jan 27, 2010 at 6:17

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

put your redirect function in your main html. On click just call parent.funcName().

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.