Advertisement

04.29.2008 at 03:44PM PDT, ID: 23363901
[x]
Attachment Details

Permission denied to call method XMLHttpRequest.open

Asked by acrxx in JavaScript

Tags: JavaScript, As many as possible, uncaught exception: Permission denied to call method XMLHttpRequest.open

Hi Everyone,

I am a bit new to AJAX, but thought I'd have a go at creating a page which will load other pages into itself, but only if the URL is available. I seem to be getting the famous "uncaught exception: Permission denied to call method XMLHttpRequest.open" in FF, even though I am not accessing the page locally and I have included netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead") which is supposed to remedy the problem.

The other annoyance I am getting is that in IE it will not allow the content to load without clicking on a button to allow to load it. This not acceptable. Any ideas on how to get round this one as well?

Any help would be greatly appreciated,

AndyStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
<html lang="en">
<head>
<title>1st attempt</title>
<script type="text/javascript">
var xmlhttp=false;   
try {
    netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
   } catch (e) {   
		alert("Permission UniversalBrowserRead denied.");
   }
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
if (window.XMLHttpRequest) {
 xmlHttp = new XMLHttpRequest();
} else if (window.ActiveXObject) {
 try {
  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch(e) {
  try {
   xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch {
   throw(e);
  }
 }
}
	
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
</script>
</head>
<body>
 
 
<script type="text/javascript">
if (xmlhttp) {
xmlhttp.open("HEAD", 'http://www.google.com',true);
 xmlhttp.onreadystatechange=function() {
 if (xmlhttp.readyState==4) {
   if (xmlhttp.status==200) document.write('<iframe src="http://www.google.com" width="700" height="700" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" hspace="0" vspace="0"/>')
  }
 }
 xmlhttp.send(null);
}
</script>
</body>
 
</html>
 
 
[+][-]04.29.2008 at 08:16PM PDT, ID: 21467858

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: JavaScript
Tags: JavaScript, As many as possible, uncaught exception: Permission denied to call method XMLHttpRequest.open
Sign Up Now!
Solution Provided By: ysfx
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.29.2008 at 09:43PM PDT, ID: 21468132

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.29.2008 at 09:44PM PDT, ID: 21468137

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628