Loading... Cancel

uncaught exception: Permission denied to get property Object.constructor R

December 30th, 2007

seems you are getting “uncaught exception: Permission denied to get property Object.constructor” while you are  executing some javascript which was instantiating some objects and during that time it stucked with some exception.

for example

function get(pUpdate, pUrl, pParams) {
new Ajax.Updater(pUpdate, pUrl, {parameters: pParams});
}

if you want to regenerate this exception you can invoke this function with the following arguments -

get(”abc”, “http://abc”)

so why this crap ?

the main reason is in your code where you mentioned about “parameters” and which is not supposed to be null. you better write the following code -

function get(pUpdate, pUrl, pParams) {
var options = new Array();
if (pParams != null) {
options[”parameters”] = pParams;
}

new Ajax.Updater(pUpdate, pUrl, options);
}
that will take away your javascript exception.

best wishes,

Google map: map.setCenter(latLng, zoomLevel) R

April 12th, 2007

Recently i am playing with Google map. it is really fun. i am thinking i will share my experience through my blog.

problem: i want to set a center point
answer: you can use map.setCenter(new GLatLng(35.746512259918504,-42.1875), 2);
here 35.xxx is lat, -42.xx is lng  and 2 is zoom level.

how to use:

1. you can use “setCenter” when you instantiating an map object. for example:
var map = new GMap2(…);
map.setCenter(..);

2. you can use after completing your initial process. for example:
setCenter after loading marker from GDowloadUrl.

best of luck :)

Customize HTML file field R

August 21st, 2006

Hi,

as we know html file field is unchangeable. you can change border style but you can’t use a button instead of traditional style.

recently i have introduced an article which clearly illustrated several examples.

though you can read it from here i am also giving my code snap.

here is live example: customized_file_field.html

<html>
<head>
<style type=”text/css”>
.file {
position: relative;
-moz-opacity:0;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
left: -160px;
}
.fake {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
</style>

</head>
<body>
<form action=”null” style=”position: relative;”>
<input type=”file” name=”file” class=”file” id=”upload-file” />
<div class=”fake”>
<input type=”button” value=”upload” />
<input type=”submit” value=”submit” />
</div>
</form>
</body>
</html>

Javascript: Delete child element with Effect.Fade (Effect.Fade and Element.remove) R

July 23rd, 2006

hi all,
let’s think you have a list of rows… when user click on delete button it sends a Ajax post request on server… after receiving JSON or XML response… it display a visual effect of destroying that row…
using Script.aculo.us you can make it with in a few seconds… new Effect.Fade(…) right!!!
but i think you DOM tree will not get that advantage as you are giving to your user… user could see visual disappearance of some object… but it is actually not deleting from DOM tree… you just hidding them… !!!

though you can use element.removeChid( childElement ) … but it is not much interactive approach as you want to show a visiual effect….

so here is my code snap… hope you will enjoy… and your visitor will happy as well as DOM tree will happy…

deleteElement: function(divId, options) {
try {
var element = $(divId);
var oldOpacity = element.getInlineOpacity();
var options = Object.extend({
from: element.getOpacity() || 1.0,
to:   0.0,
afterFinishInternal: function(effect) {
if(effect.options.to!=0) return;
var rootElement = $(BnChat.userListDiv);
rootElement.removeChild(effect.element);
effect.element.setStyle({opacity: oldOpacity});
}}, arguments[1] || {});
return new Effect.Opacity(element,options);
}
catch(e) {
// goes your exception handling
}
},