www.webdeveloper.com
Results 1 to 1 of 1

Thread: Getting "Unsafe JavaScript attempt to access frame" error

  1. #1
    Join Date
    Dec 2008
    Posts
    22

    Getting "Unsafe JavaScript attempt to access frame" error

    WebKit nightlies (but not Firefox 3+) give me an "Unsafe JavaScript attempt to access frame" error (not impacting any of the function of the code though) when I try to send messages to iframes on different domains. I'm not reading anything from the frame. Could someone tell me why I'm getting this error? Even if I am trying to access data from the iframe somewhere, the "Access-Control-Allow-Origin: *" header should make it fine.

    Here is my code (which I have hosted on http://code.sephr.net/jdata/demo1.html):
    PHP Code:
    var $tempMessageListener,
    jDataServer 'http://jdata.eligrey.com',
    jDataEnableHash false;

    var 
    jDataLoadFlags jDataEnableHash '/?hash':'/';
    var 
    jDataFrame document.createElement('iframe');
    jDataFrame.setAttribute('src'jDataServer+jDataLoadFlags);
    jDataFrame.setAttribute('style''display:none');
    document.documentElement.appendChild(jDataFrame);

    function 
    jDataQuery(querycallback) {
        if (
    callback) { $tempMessageListener = function(e){ getNextjDataResponse(ecallback); } }
        else { 
    $tempMessageListener = function(e){ getNextjDataResponse(e); } }
        
    window.addEventListener("message"$tempMessageListenerfalse);
        
    jDataFrame.contentWindow.postMessage(query'*');
    };

    function 
    getNextjDataResponse(ecallback) {
        if ( 
    e.origin == jDataServer ) { // Make sure that this is a jData response

            
    window.removeEventListener("message"$tempMessageListenerfalse);
            if (
    callback) { callback((e.data != 'null' && e.data != 'undefined')?e:undefined); }
            
    $tempMessageListener undefined;
        }
    }; 
    Last edited by Sephr; 12-18-2008 at 10:43 PM. Reason: isolated script from html, and replaced [CODE] tags with [PHP]

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles