“Permission denied to access property 'href

2019-06-09 15:55发布

This is really two questions one leading into the other. Firstly what does 'Permission denied to access property 'href' from a non-chrome context' actually mean?

Secondly I am using overlays in OpenLayers and wish to change the opacity of said layers, this is where this error is being thrown the code of which is here...

<input id='opacity' value="1.0" onChange="changeOpacity()">

Of which changeOpacity() is the following function...

function changeOpacity() {
var newOpacity = parseFloat(OpenLayers.Util.getElement('opacity').value);
newOpacity = Math.min(1.0, Math.max(0.1, newOpacity));
OpenLayers.Util.getElement('opacity').value = newOpacity;
for (var i=0; i<images.length; i++) {
layers[images[i]].setOpacity(newOpacity);
}
}

which throws the error at "var href = originalElement.href;" here...

function mD(e) {
//what is originalElement/srcElement/originalTarget?

var originalElement = e.srcElement || e.originalTarget;

 var href = originalElement.href;

  if (originalElement.nodeName == "A" && href.match("http://www.openstreetmap.org/browse/")) {

    href = href.replace('http://www.openstreetmap.org/browse/','http://www.openstreetmap.org/api/0.6/');

if (gml) { map.removeLayer(gml); } //$("status").innerHTML = 'loading'; }

gml = new OpenLayers.Layer.GML("OSM", href, {format: OpenLayers.Format.OSM});
map.addLayer(gml);
gml.preFeatureInsert = style_osm_feature; 
var sf = new OpenLayers.Control.SelectFeature(gml, {'onSelect': on_feature_hover});
map.addControl(sf);
sf.activate();
return false;

   }
} 

Any help/ideas is great appreciated! I am using firefox 3.5.9 and firebug 1.5.4

1条回答
Ridiculous、
2楼-- · 2019-06-09 15:58

I've noticed the "Permission denied.." errors often only appear when FireBug is activated. If you disable FireBug these errors never occur.

For layer opacity consider using the GeoExtJS framework on top of OpenLayers. It has a opacity slider widget:

http://www.geoext.org/lib/GeoExt/widgets/LayerOpacitySlider.html

查看更多
登录 后发表回答