2

I have a link in my jsp page .

the link looks like this

<a href="javascript:doSomething('abc.ff' , 'abc.ff?m=1')">

the javascript code

    function doSomething(url, url_progress){
    parent.win1.location.href = url;    
    /* Wait until something surely has started! */
    window.setTimeout("this.startFinally()", 1000); 
    this.startFinally = function (){
    location.href = url_progress;
      }
    }

When the user clinks on this clinks everything works fine. Now recently I put this code inside a Iframe and then nothing happens. I checked with firebug and got this error :

   Permission denied to access property 'win1'
   [Break On This Error] parent.win1.location.href = url; 

What can be the problem?

Saurabh Kumar
  • 16,353
  • 49
  • 133
  • 212
  • @Kumar Are you doing it on file:// location? – zatatatata Jul 14 '11 at 08:48
  • 1
    @Kumar I take it that you use Firebug. Could you try the same thing in Chrome and report what it logs? It looks as if it really was a cross-domain problem. I'd remind you that cross-domain also applies when you try to access `http://address` from `https://address` or via another port. – zatatatata Jul 14 '11 at 08:57

1 Answers1

14

It's possibly the same origin policy kicking in. Is everything served from the same host/port?

Waldheinz
  • 10,399
  • 3
  • 31
  • 61
  • @genesis: calm down. even if that is probably not the reason here, the answer is not 'wrong' and therefore never a downvote. – jAndy Jul 14 '11 at 08:53
  • 1
    and what's correct on this answer? It's one wrong sentence and one question. – genesis Jul 14 '11 at 08:55
  • 3
    @genesis: I can't see a wrong sentence. You don't even know if the OP probably has two domains and he is loading that iframe from an another domain. The thing I'm complaining about is, that the SOP really can be a reason for the problem. It's not wrong, "probably" (we still don't know really) in the wrong context, but thats it. That should be a downvote? come one.. – jAndy Jul 14 '11 at 08:59
  • 1
    Someone dare to explain what's up here? @genesis I really don't see how "just an iframe" rules out the SO policy. – Waldheinz Jul 14 '11 at 09:01
  • 1
    It's very likely that the SOP is the reason for the problem - see the error message. "Its just an iframe!" is a strange statement regarding SOP - Genesis, are you sure you understood what the same origin policy means regarding iframes? – Steffen Jul 14 '11 at 09:03
  • How about we just find out if it is, shall we? @genesis: what's the domain of the page executing the script/containing the iframe, and what's the domain of the iframe? – Justin Johnson Jul 14 '11 at 09:05
  • I'm maybe unknowledged, but from when iframe is not allowed to exec javascript from another domain? There's nothing about "iframe" on wiki (SOP page) – genesis Jul 14 '11 at 09:24
  • But you can't access contents in the iframe from the parent context if the contents are from another origin. There SOP applies right? I think it applies the other way around too. – phabtar Jul 16 '13 at 04:06