function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
zachzach 

"uncaught exception: Permission denied to call method XMLHttpRequest.open" Firefox only error.

Hi, just wondering if there have been any recent changes to beta 3.3... Last week, my standalone reports (non S-Control) were working fine in both Firefox and IE, but now none of the Firefox reports will work and "uncaught exception: Permission denied to call method XMLHttpRequest.open" is the error I'm getting through the javascript console.

Any ideas?

Thanks,
-Zach
gaisergaiser
Just want to confirm - same issue (standalone Firefox) here from Monday. On Friday everything was fine.
DevAngelDevAngel
Zach, can you post your code?
zachzach
Here's what I've been working on lately.  I have a lot of other examples if you'd like to see those as well.

Thanks,
-Zach

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<style type="text/css">
html,body{
 height:100%;
 width:100%;
 margin:0;
 padding:0;
}
h1 {
 margin:0;
 padding:5px 0px 5px 2px;
 font-family:verdana,arial,helvetica,sans-serif;
 font-size:11px;
 color:#333333;
}
p {
 margin:0;
 padding:5px 0px 5px 2px;
 font-family:verdana,arial,helvetica,sans-serif;
 font-size:10px;
 color:#333333;
}
input, select {
 margin:0;
 font-family:verdana,arial,helvetica,sans-serif;
 font-size:10px;
 color:#333333;
 border:1px solid #666666;
}
.button {
 background-color:#9096A1;
 border-right:1px solid #5C5D61;
 border-bottom:1px solid #5C5D61;
 border-top:0px;
 border-left:0px;
}
</style>
<!--<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js" type="text/javascript"></script>-->
<script src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js—browser=true;" type="text/javascript"></script>
<script src="http://sandbox.salesforce.com/ajax/sforceExplorer/dhtmlXCommon.js" type="text/javascript"></script>
<script src="http://sandbox.salesforce.com/ajax/sforceExplorer/dhtmlXTree.js" type="text/javascript"></script>
<script type="text/javascript">

var globalUserId;
var globalQ12 = 0;
var globalQ21b = 0;
var globalQ35 = 0;
var globalQ38 = 0;
var segmentId;
var segmentSql = new Array();

var smallLoyalArray = new Array();
smallLoyalArray['Q12'] = .0808695;
smallLoyalArray['Q21b'] = .2467170;
smallLoyalArray['Q35'] = 3.8279013;
smallLoyalArray['Q38'] = .6279676;
smallLoyalArray['con'] = -16.5581871;
var slVal = 0;

var smallPriceShopperArray = new Array();
smallPriceShopperArray['Q12'] = .0564550;
smallPriceShopperArray['Q21b'] = .1242959;
smallPriceShopperArray['Q35'] = 3.9423553;
smallPriceShopperArray['Q38'] = 1.1478419;
smallPriceShopperArray['con'] = -11.2107898;
var spsVal = 0;

var bigCasualArray = new Array();
bigCasualArray['Q12'] = .0779608;
bigCasualArray['Q21b'] = .2308613;
bigCasualArray['Q35'] = 3.1590581;
bigCasualArray['Q38'] = .1955817;
bigCasualArray['con'] = -13.1788471;
var bcVal = 0;

var bigProfessionalArray = new Array();
bigProfessionalArray['Q12'] = .1297083;
bigProfessionalArray['Q21b'] = .2388905;
bigProfessionalArray['Q35'] = 3.7263858;
bigProfessionalArray['Q38'] = .7333184;
bigProfessionalArray['con'] = -16.8984128;
var bpVal = 0;

var valueArray = new Array();

function getSegment(click) {
 setUser();
 if (click){
  reset();
  validate();
  globalQ12 = document.getElementById("Q12").value;
  globalQ21b = document.getElementById("Q21b").value;
  globalQ35 = document.getElementById("Q35").value;
  globalQ38 = document.getElementById("Q38").value;
 } else {
  getValues();
 }
 if (globalQ12 != 0 && globalQ21b != 0 && globalQ35 != 0 && globalQ38 != 0) {
  calculateSmallLoyals();
  calculateSmallPriceShoppers();
  calculateBigCasual();
  calculateBigProfessional();
  valueArray.sort(compare);
  document.getElementById("segment").innerHTML = valueArray[0][1];
 } else {
  alert ("please select values");
  document.getElementById("Q12").focus();
 }
}

function setUser(){
 sforceClient.setLoginUrl("https://www.salesforce.com/services/Soap/u/7.0");
 sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_70}", false);

 sforceClient.login("[my username]","[my password]");

 var user = sforceClient.GetUserInfo();
 globalUserId = user.userId;
 
 return true;
}

function getValues() {

 //var url = location.href;
 var url = 'https://na1.salesforce.com/00Q3000000BUAUg';
 segmentId = url.substr(url.length-15,15);
 if (segmentId.substr(0,4) == '00Q1' || segmentId.substr(0,4) == '00Q3') {
  if (segmentId.substr(0,4) == '00Q1'){
   var type = 'Account';
  }
  if (segmentId.substr(0,4) == '00Q3') {
   var type = 'Lead';
  }
 } else {
  alert ("There is no lead or account ID");
  return false;
 }

 segmentSql = sforceClient.query("Select Stated_Annual_OP_Spend__c, Pct_of_Spend_with_Primary_Supplier__c, Product_Vendor_Guidelines__c, Preferred_Rep_Visit_Frequency__c from "+type+" where Id = '"+segmentId+"'");
 //alert (segmentSql);
 
 if (segmentSql.records[0].get("stated_annual_op_spend__c") == null) {
  globalQ12 = 0;
 } else {
  globalQ12 = segmentSql.records[0].get("stated_annual_op_spend__c");
 }
 document.getElementById("Q12").value = globalQ12;

 if (segmentSql.records[0].get("pct_of_spend_with_primary_supplier__c") == null) {
  globalQ21b = 0;
 } else {
  globalQ21b = segmentSql.records[0].get("pct_of_spend_with_primary_supplier__c");
 }
 document.getElementById("Q21b").value = globalQ21b;

 if (segmentSql.records[0].get("product_vendor_guidelines__c") == null) {
  globalQ35 = 0;
 } else {
  globalQ35 = segmentSql.records[0].get("product_vendor_guidelines__c");
 }
 document.getElementById("Q35").value = globalQ35;

 if (segmentSql.records[0].get("preferred_rep_visit_frequency__c") == null) {
  globalQ38 = 0;
 } else {
  globalQ38 = segmentSql.records[0].get("preferred_rep_visit_frequency__c");
 }
 document.getElementById("Q38").value = globalQ38;

 return true;
}

function calculateSmallLoyals() {
 slVal = 0;
 valueArray[0] = new Array();
 slVal = slVal + (smallLoyalArray['Q12']*((globalQ12*1)/10000));
 slVal = slVal + (smallLoyalArray['Q21b']*(globalQ21b*1));
 slVal = slVal + (smallLoyalArray['Q35']*(globalQ35*1));
 slVal = slVal + (smallLoyalArray['Q38']*(globalQ38*1));
 slVal = slVal + smallLoyalArray['con'];
 valueArray[0][0] = slVal;
 valueArray[0][1] = 'Loyal Buyer';
 //alert(valueArray[0][1] + ': ' + valueArray[0][0]);
 return true;
}

function calculateSmallPriceShoppers() {
 spsVal = 0;
 valueArray[1] = new Array();
 spsVal = spsVal + (smallPriceShopperArray['Q12']*((globalQ12*1)/10000));
 spsVal = spsVal + (smallPriceShopperArray['Q21b']*(globalQ21b*1));
 spsVal = spsVal + (smallPriceShopperArray['Q35']*(globalQ35*1));
 spsVal = spsVal + (smallPriceShopperArray['Q38']*(globalQ38*1));
 spsVal = spsVal + smallPriceShopperArray['con'];
 valueArray[1][0] = spsVal;
 valueArray[1][1] = 'Price Shopper';
 //alert(valueArray[1][1] + ': ' + valueArray[1][0]);
 return true;
}

function calculateBigCasual() {
 bcVal = 0;
 valueArray[2] = new Array();
 bcVal = bcVal + (bigCasualArray['Q12']*((globalQ12*1)/10000));
 bcVal = bcVal + (bigCasualArray['Q21b']*(globalQ21b*1));
 bcVal = bcVal + (bigCasualArray['Q35']*(globalQ35*1));
 bcVal = bcVal + (bigCasualArray['Q38']*(globalQ38*1));
 bcVal = bcVal + bigCasualArray['con'];
 valueArray[2][0] = bcVal;
 valueArray[2][1] = 'Casual Buyer';
 //alert(valueArray[2][1] + ': ' + valueArray[2][0]);
 return true;
}

function calculateBigProfessional() {
 bpVal = 0;
 valueArray[3] = new Array();
 bpVal = bpVal + (bigProfessionalArray['Q12']*((globalQ12*1)/10000));
 bpVal = bpVal + (bigProfessionalArray['Q21b']*(globalQ21b*1));
 bpVal = bpVal + (bigProfessionalArray['Q35']*(globalQ35*1));
 bpVal = bpVal + (bigProfessionalArray['Q38']*(globalQ38*1));
 bpVal = bpVal + bigProfessionalArray['con'];
 valueArray[3][0] = bpVal;
 valueArray[3][1] = 'Sophisticated Buyer';
 //alert(valueArray[3][1] + ': ' + valueArray[3][0]);
 return true;
}

function compare(recordA, recordB) {

 if (recordA[0] > recordB[0]) return -1;
 if (recordA[0] < recordB[0]) return 1;
 return 0;

}

function validate() {
 if (!document.getElementById("Q12").value) {
  alert("Q12: Please enter a value");
  document.getElementById("Q12").focus();
  return false;
 }
 if (document.getElementById("Q12").value.indexOf(",") != -1) {
  str = document.getElementById("Q12").value;
  str = str.replace(/,/g,"");
  document.getElementById("Q12").value = str;
 }
 if (document.getElementById("Q12").value.indexOf("$") != -1) {
  str = document.getElementById("Q12").value;
  str = str.replace(/\$/g,"");
  document.getElementById("Q12").value = str;
 }
 else if (isNaN(document.getElementById("Q12").value)) {
  alert("Q12: Please enter a number");
  document.getElementById("Q12").focus();
  return false;
 }
 else if (!document.getElementById("Q21b").value) {
  alert("Q21b: Please enter a value");
  document.getElementById("Q21b").focus();
  return false;
 }
 else if (isNaN(document.getElementById("Q21b").value)) {
  alert("Q21b: Please enter a number");
  document.getElementById("Q21b").focus();
  return false;
 } else { return true; }
}

function submitSegment() {
 if (confirm("Are you sure you want to update these values in Salesforce–")) {
  if (valueArray[0]) {
   var updateArray = new Array();
   var _value = segmentSql.records[0]
   _value.set('id',segmentId);
   _value.set('stated_annual_op_spend__c',globalQ12);
   _value.set('pct_of_spend_with_primary_supplier__c',globalQ21b);
   _value.set('product_vendor_guidelines__c',globalQ35);
   _value.set('preferred_rep_visit_frequency__c',globalQ38);
   _value.set('predicted_attitudinal_segment__c',valueArray[0][1]);
   updateArray.push(_value);

   var updateVal = sforceClient.Update(updateArray);
   //alert(updateVal);
   alert('Your changes have been saved');
   window.location.reload();
  } else {
   alert("Please press the 'calculate segment' button before submitting values");
   return false;
  }
 } else {
  return false;
 }
}

function reset() {
 valueArray.length = 0;
 globalQ12 = 0;
 globalQ21b = 0;
 globalQ35 = 0;
 globalQ38 = 0;
 return true;
}

</script>
</head>
<body onLoad="getSegment();">
 <table width='600' border='0' cellpadding='2' cellspacing='0'>

  <tr>
   <td width='220' style='border-top:7px solid #E39321;border-bottom:2px solid #E39321;border-left:0px;'>
    <h1>Attitudinal Segmentation</h1>
   </td>
   <td align='left' style='border-top:7px solid #E39321;border-bottom:2px solid #E39321;border-left:0px;'>
    <input type="button" name="calculate" value=" calculate " class='button' style="color:#FFFFFF;font-weight:bold;" onClick="getSegment(1)"/> <input type="button" name="submit" value=" submit " class='button' style="color:#FFFFFF;font-weight:bold;" onClick="submitSegment()"/>
   </td>
   <td style='border-top:7px solid #E39321;border-bottom:2px solid #E39321;'>
    <p>&nbsp;</p>
   </td>
  </tr>
 </table>
 <table width='600' border='0' cellpadding='2' cellspacing='0'>
  <tr>
   <td colspan='3' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
  <p><b>Instructions:</b><br/>Put answers to questions in the cells, click the "calculate" button, and the segmentation prediction will appear at the bottom of the table. Click the "submit" button to save these values to salesforce.</p>
   </td>
  </tr>
  <tr>
   <td width='200' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p><b>Field</b></p>
   </td>
   <td width='430' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p><b>Survey Question</b></p>
   </td>
   <td width='270' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p><b>Value</b></p>
   </td>
  </tr>
  <tr>
   <td width='200' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p><b>Stated Annual OP Spend</b></p>
   </td>
   <td width='430' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p>How much did your company spend on office supplies in the past 12 months˜</p>
   </td>
   <td width='270' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p>$<input type="text" name="Q12" id="Q12" size="10" /></p>
   </td>
  </tr>
  <tr>
   <td width='200' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p><b>% of Spend with Primary Supplier</b></p>
   </td>
   <td width='430' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p>What percentage of total dollars spent on office supplies were spent with your primary vendor™</p>
   </td>
   <td width='270' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p><input type="text" name="Q21b" id="Q21b" size="3" maxlength="3" />%</p>
   </td>
  </tr>
  <tr>
   <td width='200' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p><b>Product/Vendor Guidelines</b></p>
   </td>
   <td width='430' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p>How would you characterize your policies for office supply purchases?</p>
   </td>
   <td width='270' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <select name="Q35" id="Q35" style="float:left;">
     <option value="0">please select</option>
     <option value="1">No guidelines on vendors or products</option>
     <option value="2">Guidelines on vendors, none on products</option>
     <option value="3">Guidelines on products, none on vendors</option>
     <option value="4">Guidelines on both vendors and products</option>
    </select>
   </td>
  </tr>
  <tr>
   <td width='200' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p><b>Referred Rep Visit Frequency</b></p>
   </td>
   <td width='430' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <p>How often do you want to talk in person to a representative from your current "primary" office supplies company?</p>
   </td>
   <td width='270' style='background-color:#F3F3EC; border-bottom:1px solid #E3DEB8;'>
    <select name="Q38" id="Q38" style="float:left;">
     <option value="0">please select</option>
     <option value="8">Weekly</option>
     <option value="7">Every 2-3 Weeks</option>
     <option value="6">Monthly</option>
     <option value="5">Every 2-3 Months</option>
     <option value="4">Every 4-5 Months</option>
     <option value="3">Semi-Annually</option>
     <option value="2">Annually</option>
     <option value="1">Never</option>
    </select>
   </td>
  </tr>
  <tr>
   <td colspan='3' style='border-bottom:3px solid #E39321;'>
    <p><b>Segmentation Prediction:</b> <span id='segment'></span></p>
   </td>
  </tr>
 </table>
</body>
</html>

 

DevAngelDevAngel

Right, there was a regression.  I have fixed the bug and have queued the fix for publication, but have not recieved a publication commitment yet. 

The workaround is to add this line of code to the function that runs for the body onload event.

 

if (window.XMLHttpRequest) sforceClient.appType = Sforce.Application.Type.FireFox;

 

This should be the first line of code in your body onload event handler.

SteveBowerSteveBower
Confirming: The issue still stands from Firefox on Friday 4/14/06.  Steve Bower.

P.S. Is the browsersupport.js file going to be considered "part of" the Ajax client, version controlled, etc. whenever this eventually goes Production? 

RichardC.ax220RichardC.ax220
In Firefox, I set signed.applets.codebase_principal_support to true
in addition to DevAngel's
    if (window.XMLHttpRequest) sforceClient.appType = Sforce.Application.Type.FireFox;
so I can get on with development.

Richard C
BLBL
Any Mozilla based browser (Firefox, Camino, etc.) will return this error when you try to execute XMLHttpRequests from one domain to another (http://yoursite.com to www.salesforce.com/services/Soap/u/11.0 for example).

To get around this you need to disable cross site scripting protection within hidden preferences in Firefox or other Mozilla based browsers and add a line of code to your javascript library:

netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");

I've posted details on how to fix Permission denied to call method XMLHttpRequest.open with respect to the Ajax Toolkit on my blog. The solution should be workable for your situation as well.