Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2004
    Posts
    49
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Javascript "Access is Denied" error message - help!

    Hi

    I have developed an internet mapping site which uses an html viewer with various frames to pull in a mapping window, a legend / key and a frame of tools amongst other things.

    It works absolutely fine in Internet Explorer version 6, but whilst testing it in Internet Explorer 7, my mapping window is not loading up the image.

    It might seem strange me posting this in a javascript forum but as the error is javascript related I thought I would give it a shot!

    The error message I am receiving is "Access is denied".

    After looking online, it appears as though this error could be linked to the use of frames; and those frames trying to access other windows with different document domains?? Does anyone know if new security measures have been implemented in IE7 which restricts the use of frames?

    My code is below; does anyone notice anything that might give this kind of javascript error?

    Any help will be greatly appreciated as I do not tend to dable too much in javascript!

    Code:
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <TITLE>Intranet GIS Service</TITLE>
    <HTML>
    <HEAD>
    	<SCRIPT LANGUAGE="JavaScript" SRC="javascript/aimsResource.js" TYPE="text/javascript"></SCRIPT>
    	<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">	
    		
    		// Designer will set the next variable - theTitle
    		//var theTitle = "Intranet GIS";
    		var theTitle = "";
    		if (theTitle.indexOf("###TITLE##")!=-1) theTitle = titleList[0];
    		var cmdString = document.location.search;
    
    		var webParams = cmdString;
    		var reloadTimer=0;
    		document.writeln("<TITLE>" + theTitle + "</TITLE>");
    		
    		function doIt() 
    		{
    			MapFrame.useJava=false;
    			MapFrame.checkParams();
    		}
    		function replacePlus(inText) 
    		{
    		     var re = /\+/g;
    		      inText = inText.replace(re," ");
    		     return inText;
    		}
    		
    		function reloadApp() 
    		{
    			//window.clearTimeout(reloadTimer);
    			//reloadTimer = window.setTimeout("document.location.href = 'viewer.jsp' + cmdString",1000);
    			
    			//Above code replaced with this. Only the map should refresh after a resize, otherwise
    			//all added datashare layers are lost.
    
    			MapFrame.mWidth = MapFrame.getMapWidth();
    			MapFrame.mHeight = MapFrame.getMapHeight();
    			MapFrame.sWidth = screen.width;
    			MapFrame.sHeight = screen.height;
    			MapFrame.loadBannerLeft = parseInt((MapFrame.mWidth - 119)/2);
    			MapFrame.loadBannerTop = parseInt((MapFrame.mHeight - 72)/2);
    			MapFrame.document.getElementById("theMap").style.width = MapFrame.sWidth;
    			MapFrame.document.getElementById("theMap").style.height = MapFrame.sWidth;
    			
    			MapFrame.iWidth = MapFrame.mWidth;
    			MapFrame.iHeight = MapFrame.mHeight;
    			
    			MapFrame.legHeight = MapFrame.iHeight - 160;
    						
    			var cmd = 'MapFrame.sendMapXML();';
    			cmd += 'MapFrame.document.getElementById("theImage").style.width = MapFrame.mWidth;';
    			cmd += 'MapFrame.document.getElementById("theImage").style.height = MapFrame.mHeight;';
    			
    			window.clearTimeout(reloadTimer);
    			reloadTimer = window.setTimeout(cmd,1000);
    		}	
    	
    	</SCRIPT>
    </HEAD>
    
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    	var browser = navigator.appName;
    	var moreStuff = 'onresize="reloadApp()"';
    	var addNS = 0;
    	if (browser=="Netscape") 
    	{
    		addNS = 3;
    	}
    	document.writeln('<FRAMESET ROWS="' + (45+addNS) + ',*,30,0" FRAMEBORDER="No" FRAMESPACING="0" onload="doIt()" BORDER=2 ' + moreStuff + '>');
    	document.writeln('<FRAME NAME="TopFrame" SRC="topbar.htm" MARGINWIDTH="5" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE>');
    	document.writeln('<FRAMESET COLS="' + (30+addNS) + ',*,270" FRAMEBORDER="No" FRAMESPACING="0" BORDER="2">');
    	
    </SCRIPT>
    		<FRAME NAME="TextFrame" SRC="text.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE FRAMESPACING="0" BORDER="2">
    		
    		<!-- If textframe is used-->
    		<FRAMESET ROWS="*,115">	
    			<FRAME NAME="MapFrame" SRC="MapFrame.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="Yes" RESIZE="YES">
    			<FRAME NAME="ToolFrame" SRC="blank.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="Auto" FRAMEBORDER="No" RESIZE="YES">
    		</FRAMESET> 
    		 
    		<!-- If textframe is not used -->
    		<!--<FRAME NAME="MapFrame" SRC="MapFrame.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" RESIZE="YES">-->
    		
    		<FRAME NAME="TOCFrame" SRC="TOCFrame.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="Auto" FRAMEBORDER="No" RESIZE="YES">
    	</FRAMESET>
    	<FRAMESET COLS="400,*" FRAMEBORDER="Yes" BORDER=2 FRAMESPACING="0">
    		<FRAME NAME="ModeFrame" SRC="bottom.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE>
    		<FRAME NAME="ModeFrame" SRC="bottom.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE>
    	</FRAMESET>
    	<FRAME NAME="PostFrame" SRC="jsForm.htm" MARGINWIDTH="0" MARGINHEIGHT="0" SCROLLING="No" FRAMEBORDER="No" NORESIZE FRAMESPACING="0" BORDER="2">
    </FRAMESET>
    
    <NOFRAMES>
    <BODY>
    <P>
    </BODY>
    </NOFRAMES>
    </HTML>

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    For security reasons JavaScript cannot access anything beyond the domain of the current page. This is known as the "same origin policy" and prevents a document or script loaded from one origin from getting or setting properties of a document from a different origin.

    The problem you are having appears to be an IE7 (only) bug - see Having a Problem With an 'Access is Denied' Error, Only In IE7, although no solution was provided.

    The problem is that if the main page comes from x.mysite.com and the src of the iframe comes from
    y.mysite.com and both set document.domain='mysite.com'; they still won't be able to look at each other unless both x.mysite.com and y.mysite.com are explicitly added to the "Trusted Websites" list in the user's browser.


    It is your responsibility to die() if necessary….. - PHP Manual
    Last edited by Philip M; 12-11-2009 at 11:44 AM.

  • #3
    New Coder
    Join Date
    Apr 2004
    Posts
    49
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you for your response Philip.

    Being somewhat of a javascript novice I am trying to find out what exactly is the problem with my code (it was created quite a few years back thus I am not too familiar with how it is set up).

    Do you have any clues as to why every frame apart from the main mapping frame are loading correctly? Could the main mapping frame be the only one changing the document domain?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    I am afraid that attempting to diagnose your exact problem is rather like trying to learn to swim by correspondence course. That is the best I can do! If it works in IE6 and IE8 but not in IE7 then it is an IE7 bug and nothing much can be done about it.


  •  

    Posting Permissions

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