SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Permission Denied Error

    I get JavaScript Permission Denied error while trying to call a JS function from the OPENER page. I am aware of the “SAME ORIGIN POLICY” of JavaScript which prevents document or script loaded from one origin from getting or setting properties of a document from a different origin.

    I will explain the scenario.

    I have a Main page with several Iframes in it. One of the frames has a page (let’s call it Opener)which has a button on it, onclick of which a pop up window opens. The script to open the page comes from the database entry.

    javascriptarent.openWindow("../loading.aspx?forwardUrl=./Report/Adhoc/Theme/popup.aspx!floor={0}","adhoctheme", "status=no,toolbar=no,directories=no,scrollbars=no,menubar=no,resizable=no,width=950,height=700")

    // Open window is JS function defined in the Main page.

    In the popup page I have a link which calls the JS function of the Main page. While clicking this link to call the JS function I get the permission denied error.
    The onclick event of link fires the following Jscript function.

    function refreshFloorPlan()
    {
    var floorIdEle = document.getElementById("_floorId");
    if (floorIdEle != null)
    {
    opener.parent.parent.refreshFloorPlan(floorIdEle.value);
    }
    }


    There is absolutely no problem in getting the opener page and though getting the opener.parent.parent page.
    The problem starts when I reload the opener.parent page through the JS function which is in opener.parent.parent page.
    For the first time it works perfectly fine. But from second time onwards, ( the page is reloaded in the first instance), it doesn't permit me to access it.

    Here is the JS function ( present in the opener.parent.parent)

    // function refreshFloorPlan()
    function displayRFP(locCode, flr)
    {
    _breadCrumbCallback.Callback("floor#" + locCode+"#"+flr);
    var frameUrl = "./loading.aspx?forwardUrl=./Viewer/Viewer.aspx!"; frameUrl = frameUrl + "floorId=" + flr +"|view=floormap" ;
    var param = "floor#"+flr+"$ dummy"; _detailMenuCallback.Callback(param);
    MapFrame.document.location = frameUrl; var urlParam = "facility=" + "|bldg=|floor="+flr+"|space=|report=floor|mode=";
    var basePageUrl="./loading.aspx?forwardUrl=";
    updateLocationSummary(urlParam, basePageUrl);
    }

    If I do some other operation like getting an element from opener.parent.parent page, everything works fine.
    I guess whenever the page is reloaded, it assumes that the domain has been changed, whereas the domain is still "localhost" for all the pages.


    Please note the domain of all the page is localhost.

    Could anyone please give me some clue to resolve this issue.

    Thanks in advance

    -S
    Last edited by satyajitg; Jul 2, 2007 at 04:17. Reason: More explanation

  2. #2
    SitePoint Evangelist dmsuperman's Avatar
    Join Date
    Feb 2005
    Location
    A box
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps the popup window can't reach that far back for executing JavaScript?

    Try having it so the popup executes some JavaScript on it's opener, which in turn will execute some code on it's parent page.
    <(^.^<) \(^.^\) (^.^) (/^.^)/ (>^.^)>
    Core 2 Duo E8400 clocked @ 3.375GHz, 2x2GB 800MHz DDR2 RAM
    5x SATA drives totalling 2.5TB, 7900GS KO, 6600GT

  3. #3
    SitePoint Member
    Join Date
    Jun 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Tried breaking up the calling code

    Hey..thanks for replying. Yeah, I did try your suggestion before. The issue is, the code doesn't recognize or doesn't allow to execute anything from the OPENER page for the second time. So I am not able to call the script present in the opener page.
    I have added more explanation in my previous question if you want to have a look at the issue.


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
  •