function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
theitdeptrockstheitdeptrocks 

Javascript: Error: Permission denied to access property 'document'

I have a standard page layout and within it, one section contains a VF page.  The VF page is fairly empty, except for a body onload javascript that creates a div and attempts to append it to the parent.

 

The section of the layout that contains the div is at the bottom of the page, but I'm trying to create the div so that it is fixed at the top of the page.

 

The div is created OK when you are just looking at the VF page alone, but trying it embedded within a layout results in that error message.

 

Does anyone have any ideas to fix that?

 

Thanks in advance!

 

<apex:page sidebar="false" showHeader="false" standardController="Opportunity">
<head>
<style type="text/css">
td.head{
    color: #4A4A56;
    font-weight:bold;
    text-align: right;
    padding-right: 10px;
    }
    
</style>
<script type="text/javascript" src="/soap/ajax/15.0/connection.js" > </script> 
<script type="text/javascript" src="/js/functions.js"></script> 
<script type="text/javascript">
function load()
{
try{
var newdiv = parent.document.createElement('div');
newdiv.setAttribute('id', "thepanel");
newdiv.style.width = "50px";
newdiv.style.height = "50px";
newdiv.style.position = "fixed"; 
newdiv.style.left = "220px";
newdiv.style.top = "0px";
newdiv.style.background = "#000000";
newdiv.style.border = "1px solid #000";
newdiv.style.zIndex = "9999";
newdiv.style.padding = "0px";
newdiv.innerHTML = "test"; 
parent.document.body.appendChild(newdiv);
}catch(error){
alert('error :'+error);
}
}
</script>
</head>
<html>
<body onload="load()">

</body>
</html>


</apex:page>