最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Getting "prompt aborted by user" javascript exception - Stack Overflow

programmeradmin1浏览0评论

I am getting "Components.Exception("prompt aborted by user", Cr.NS_ERROR_NOT_AVAILABLE)" exception when I am using "windows.location.href" in javasacript. My Code is:

function checkCookie(){
var value = null;   
var cookieName='UserDetailsCookie'; 
value=ReadCookie(cookieName);   
if(value != null){          
    var url='<%=request.getContextPath()%>/jsp/admin.jsp';
    window.location.href = url;     
}
document.loginForm.userName.focus();

}

function ReadCookie(name)
{
  name += '=';
  var parts = document.cookie.split(/;\s*/);
  for (var i = 0; i < parts.length; i++)
  {
    var part = parts[i];
    if (part.indexOf(name) == 0)
          return part.substring(name.length);
      }
  return null;

}

and I am calling this method on onLoad event of body

<body onLoad="javascript:checkCookie();">

In anyone knows why this exception throws please?

I am getting "Components.Exception("prompt aborted by user", Cr.NS_ERROR_NOT_AVAILABLE)" exception when I am using "windows.location.href" in javasacript. My Code is:

function checkCookie(){
var value = null;   
var cookieName='UserDetailsCookie'; 
value=ReadCookie(cookieName);   
if(value != null){          
    var url='<%=request.getContextPath()%>/jsp/admin.jsp';
    window.location.href = url;     
}
document.loginForm.userName.focus();

}

function ReadCookie(name)
{
  name += '=';
  var parts = document.cookie.split(/;\s*/);
  for (var i = 0; i < parts.length; i++)
  {
    var part = parts[i];
    if (part.indexOf(name) == 0)
          return part.substring(name.length);
      }
  return null;

}

and I am calling this method on onLoad event of body

<body onLoad="javascript:checkCookie();">

In anyone knows why this exception throws please?

Share Improve this question asked Nov 21, 2011 at 11:39 Bhagwat GurleBhagwat Gurle 3432 gold badges8 silver badges19 bronze badges 3
  • I get the same error when doing a jQuery.ajax call. stackoverflow./questions/8703317/… – JustBeingHelpful Commented Jan 2, 2012 at 20:02
  • @MacGyver: Thanks for reply, it's already resolve for me. – Bhagwat Gurle Commented Jan 3, 2012 at 7:21
  • 5 If you solved it, can you write your solution as an answer please. – TryHarder Commented Jun 3, 2012 at 2:21
Add a ment  | 

1 Answer 1

Reset to default 3

I'm not 100% sure, but I think this is due to the line

document.loginForm.userName.focus();

because this will cancel the loading of your URL done with the window.location.href = 'xxx'.

Anyway, in general there should NOT be any line of code after setting the location.href property.

Hope that helps, I know it's old but I answered for moomoochoo since his ment isn't "that" old.

发布评论

评论列表(0)

  1. 暂无评论