AttachEvent - permission denied ?

A

Adrian Parker

Using asp.net 2003

When I use

document.attachEvent("onmousemove", resetTimer);

The first time into a page, it works fine, but the 2nd time the page is
loaded (not postback) it gives a permission denied error.. any ideas why ?

Thanks
-Adrian
 
M

Martin Honnen

Adrian said:
Using asp.net 2003

When I use

document.attachEvent("onmousemove", resetTimer);

The first time into a page, it works fine, but the 2nd time the page is
loaded (not postback) it gives a permission denied error.. any ideas why ?

You usually get that error message when your script tries to access a
document in another frame or window it doesn't have access to due to the
same origin policy only allowing access to window/frames with documents
being loaded from the same host/domain.
Are you using any frames or popup windows, does resetTimer try to access
data in another window/frame?
 
A

Adrian Parker

You usually get that error message when your script tries to access a
document in another frame or window it doesn't have access to due to the
same origin policy only allowing access to window/frames with documents
being loaded from the same host/domain.
Are you using any frames or popup windows, does resetTimer try to access
data in another window/frame?

I am using frames, but the pages in the other 2 frames do not have this code
in them.

Here's the code.. first time in is ok, it's the 2nd time the page is loaded
that has the problem with the attachevent.

<script>

var SRV_IDLE_TIME = 1200000;
var srv_timerID = -1;
var CLI_IDLE_TIME = 900000;
var cli_timerID = -1;

// On page load, start times and set focus
function onLoading() {
startTimer();
placeFocus();
}

// Clear timers when page unloaded
function onUnloading() {
if (cli_timerID != -1) {
clearTimeout(cli_timerID);
}
if (srv_timerID != -1) {
clearTimeout(srv_timerID);
}
}

// Start Timers
function startTimer() {
cli_timerID = window.setTimeout("timeOut()",CLI_IDLE_TIME);
srv_timerID = window.setTimeout("timeOut()",SRV_IDLE_TIME);
}

// Restart the client side inactivity timer
function resetTimer() {
if (cli_timerID != -1) {
clearTimeout(cli_timerID);
cli_timerID = window.setTimeout("timeOut()",CLI_IDLE_TIME);
}
}

// Client side inactivity timeout
function timeOut() {
if (cli_timerID != -1) {
clearTimeout(cli_timerID);
}
cli_timerID = -1;
if (srv_timerID != -1) {
clearTimeout(srv_timerID);
}
srv_timerID = -1;
location.href='logout.aspx';
}

function placeFocus() {
if( Form1.elements[0]!=null) {
var i;
var max = Form1.length;
for( i = 0; i < max; i++ ) {
if( Form1.elements[ i ].type != "hidden" &&
!Form1.elements[ i ].disabled &&
!Form1.elements[ i ].readOnly &&
(Form1.elements[ i ].type == "text" ||
Form1.elements[ i ].type == "textarea") ) {
Form1.elements[ i ].focus();
break;
}
}
}
}

document.attachEvent("onmousemove", resetTimer);
document.attachEvent("onclick", resetTimer);
document.attachEvent("onkeydown", resetTimer);

</script>

<body onload="onLoading();" onunload="onUnloading();" .....etc
 
M

Martin Honnen

Adrian Parker wrote:

I am using frames, but the pages in the other 2 frames do not have this code
in them.

Here's the code.. first time in is ok, it's the 2nd time the page is loaded
that has the problem with the attachevent.

Odd, there is indeed nothing in the code that tries to access another
frame and could therefore cause a permission denied. I don't know why
you get the error.
 
J

Jim Ley

Odd, there is indeed nothing in the code that tries to access another
frame and could therefore cause a permission denied. I don't know why
you get the error.

I've seen this sort of thing recently onload, never seen it with my
code so never looked into it - I think it may be related to IE doesn't
fully recompile the code on an F5 refresh if the docs haven't changed.

It'd be good to reproduce a test-case and finally look at this I think
- can the OP get the files on line - preferably reduced to the minimum
that exhibits the problem.

Jim.
 
A

Adrian Parker

I've seen this sort of thing recently onload, never seen it with my
code so never looked into it - I think it may be related to IE doesn't
fully recompile the code on an F5 refresh if the docs haven't changed.

It'd be good to reproduce a test-case and finally look at this I think
- can the OP get the files on line - preferably reduced to the minimum
that exhibits the problem.

Jim.

Hmm.. this is odd.. same code running on a non-dev win2k box runs fine.
my dev box is running win2k sp2.

I'll try to mock up a single page with the script on it.

-Adrian
 
A

Adrian Parker

Finally found the problem. At server side I was doing a response.redirect
which doesn't work properly.. if I change it to use server.transfer it works
fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top