473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

preventing Access/Permission Denied errors

OK Guys and Gals,

I've got a script that does some work with the document object in
another frame.

This works fine until the other frame contains a document on another
domain. This of course produces a permission error.

I don't actually want to do anything with the document if the page is
on a different domain BUT I do want to detect this situation before it
occurs, and then allow my script to terminate peacefully instead of
producing an error.

How can I do this?

I suppose I could use IE's try and catch, but that means I'll still
have problems on other browsers.

All suggestions gratefully received.

Cheers

N
Jul 23 '05 #1
5 5725
Ron
Nick wrote:
[snip]

I suppose I could use IE's try and catch, but that means I'll still
have problems on other browsers.

try{...} catch{...} isn't IE, it's ECMAScript 3
<http://www.ecma-international.org/publications/standards/Stnindex.htm>,
which Javascript 1.5 is an implementation of. I've used try{...}
catch{...} on Mozilla and Firefox with no problems.
Jul 23 '05 #2
Nick wrote:
<snip>
I don't actually want to do anything with the document if the page is
on a different domain BUT I do want to detect this situation before it
occurs, and then allow my script to terminate peacefully instead of
producing an error.

How can I do this?

I suppose I could use IE's try and catch, but that means I'll still
have problems on other browsers.

<snip>

They aren't IE's try-catch, they are specified in ECMA 262 3rd edition,
and implemented in JavaScript 1.4+, but they do represent a syntax error
in all earlier versions so are generally best avoided in cross-browser
scripting (at least for another couple of years).

You cannot determine that a document in the other frame is from a
different domain because of the security restrictions, as you have
discovered. But you don't really need to as all you actually need to
know is whether the page in the other frame is from your domain, and
thus safe to interact with. Your own pages are in a position to report
their presence to the frameset.

So, for example, you could have each of your own pages set a variable in
the frameset to true from it's onload event, and then re-set that
variable to false in its onunload event. You would then know that it was
safe to interact with the other frame whenever the variable was set to
true and unsafe whenever it was false.

Richard.
Jul 23 '05 #3
How can I add a safe domain? I get an access error when doing this
document.all("dynamicFrame"); //my iframe

function iframeResize() {
var oBody = dynamicFrame.document.body;
var oFrame = document.all("dynamicFrame");
oFrame.style.height = oBody.scrollHeight
+oBody.offsetHeight-oBody.clientHeight;

//This is the alert call that miraculously makes this function
alert(caller +" oFrame.style.height = " +oFrame.style.height);
}

//Description:Initializes the page by creating the scroll objects
//setting browser specific information
function InitializePage(){
//d_bw.ns4||d_bw.ns5?"":iframeResize();
setTimeout("iframeResize()",2000);
//iframeResize();
}
<IFRAME APPLICATION="yes" style="width:100%;" ID="dynamicFrame"
NAME="dynamicFrame" frameborder="no" scrolling="no"
SRC="https://mydomain.com/page.jsp"> Sorry, you need inline frames to fully
see this page. </IFRAME>

"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:c7*******************@news.demon.co.uk...
Nick wrote:
<snip>
I don't actually want to do anything with the document if the page is
on a different domain BUT I do want to detect this situation before it
occurs, and then allow my script to terminate peacefully instead of
producing an error.

How can I do this?

I suppose I could use IE's try and catch, but that means I'll still
have problems on other browsers.

<snip>

They aren't IE's try-catch, they are specified in ECMA 262 3rd edition,
and implemented in JavaScript 1.4+, but they do represent a syntax error
in all earlier versions so are generally best avoided in cross-browser
scripting (at least for another couple of years).

You cannot determine that a document in the other frame is from a
different domain because of the security restrictions, as you have
discovered. But you don't really need to as all you actually need to
know is whether the page in the other frame is from your domain, and
thus safe to interact with. Your own pages are in a position to report
their presence to the frameset.

So, for example, you could have each of your own pages set a variable in
the frameset to true from it's onload event, and then re-set that
variable to false in its onunload event. You would then know that it was
safe to interact with the other frame whenever the variable was set to
true and unsafe whenever it was false.

Richard.

Jul 23 '05 #4
Cindy Lee wrote:
How can I add a safe domain?
Questions of that quality are likely to receive fatuous answers. What on
earth are you talking about?
I get an access error when doing this
document.all("dynamicFrame"); //my iframe

<snip>

Yes, that is a statement that is likely to produce an error of one sort
or another in most browsers.

Richard.
Jul 23 '05 #5
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message news:<c7*******************@news.demon.co.uk>...

<snip>

They aren't IE's try-catch, they are specified in ECMA 262 3rd edition,
and implemented in JavaScript 1.4+, but they do represent a syntax error
in all earlier versions so are generally best avoided in cross-browser
scripting (at least for another couple of years).
Hmmm... I share your concerns about cross browser scripting, even if
try...catch is available on other browsers. The kind of people my
application is written for may well have older browsers with older
versions of js.

So, for example, you could have each of your own pages set a variable in
the frameset to true from it's onload event, and then re-set that
variable to false in its onunload event. You would then know that it was
safe to interact with the other frame whenever the variable was set to
true and unsafe whenever it was false.


Richard, this is an excellent suggestion. Unfortunately I cannot add
any js to the pages on the domain I am working on! The script I was
talking about runs on a page which acts as a kind of "client
statistics utility" for a customer's web site. I can't then ask my
customers to alter all of their pages (either by adding some code or
src-ing a js file). It's just not viable.

I appreciate the suggestion though, and if you or any others can think
of a viable alternative to try...catch that would be great. Otherwise,
looks like I've got to do some js version detection, and have to
prevent users with js 1.4 downwards from using my utility. Bummer.

Cheers for your continuing help! ;)

N
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Salty Dog | last post by:
Code: <%Response.Buffer = False%> <HTML> <HEAD> <title>Printing</title> </HEAD> <BODY> <center> <% FilePath = "c:\WUTemp\441817810_receiver.txt"
1
by: Benny | last post by:
Dear All, My ASP-MS Access application works fin in our local server and in our hosting I get this errors, while adding/editing or deleteing. When deleting a product: error Microsoft VBScript...
4
by: Jason Hurder | last post by:
Hello folks, I am experiencing a rather strange problem. I have written a service that attempts to open a file on a network share via a FileStream object. When I try to open the file from my...
2
by: Cédric Rossé | last post by:
Hello, I'm currently developping a web application and I'm trying to execute a batch file (.cmd) on the server side when the client presses a button on a web page. When I do this on my local...
3
by: David Thielen | last post by:
Hi; I created a virtual directory in IIS 6.0 and my asp.net app runs fine. But when it tries to write a file I get: Access to the path is denied. - C:\Inetpub\wwwroot\RunReportASP\images ...
2
by: job | last post by:
In a sharepoint setup using smartpart to load our user controls using enterprise blocks (data) we are getting some strange errors (logged to the event log). We dont get the error all the time. When...
0
by: debug03 | last post by:
I am executing a DTS package on a Windows 2000 sp4 server running SQL Server 2000 and IBM DB2 V7 client. The DTS package source data(SQL Server) is selected from SQL server table and inserts data to...
2
by: P1 | last post by:
Hey guys, I'm totally out of my league here, I don't even know how I got stuck with this problem, it's obviously a webmaster issue and I'm just a lowly net admin. The error: Starts here...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.