SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript - Access is Denied error

    I have two servers jboss and ejabbered and i have deployed two html files, one on each as follows:

    testdirver.html deployed on ejabbered
    <html><head>
    <script>
    function viewmembers()
    {var w=window.open("http://192.168.56.134:8080/nkms1/kms/test.html");}
    </script>
    </head>
    <body><form name="sub" >
    <input type="text" id="to" name="to">
    <button onClick= "viewmembers();">
    </form></body></html>

    test.html on jboss
    <html>
    <script>
    function abc()
    {alert(window.opener.document.forms[0].to);}
    </script>
    <body onload=abc();></body></html>

    Problem: window.opener.document gives the js error "Access is Denied" which i am not able to understand.

    Exchanging the two files on the servers(i.e. testdriver.html on jboss and test.html on ejabbered works fine and i get the output [object]). So i am guessing there is something that has to do with the ejabbered server

  2. #2
    SitePoint Member
    Join Date
    Sep 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.

    You will find that JavaScript restricts access to cross-domain requests.

    This is a security mechanism built into the browser.

    You will only be able to access resources on the same server.

    Phil.

  3. #3
    SitePoint Member
    Join Date
    Dec 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Thanks for your response, but please check the last line - "Exchanging the two files on the servers(i.e. testdriver.html on jboss and test.html on ejabbered works fine and i get the output [object]). So i am guessing there is something that has to do with the ejabbered server."

    Why is this working in that case?

    Regards

    Nitin


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •