...

View Full Version : Javascript "Access is Denied" error message - help!



Buckster_uk
12-11-2009, 11:34 AM
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!



<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>

Philip M
12-11-2009, 12:23 PM
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 http://codingforums.com/showthread.php?t=167884, 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

Buckster_uk
12-11-2009, 04:12 PM
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?

Philip M
12-11-2009, 05:45 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum