Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > greasemonkey specific javascript irregularities

Reply
Thread Tools

greasemonkey specific javascript irregularities

 
 
bosky101@gmail.com
Guest
Posts: n/a
 
      06-04-2006
alright ive heard a lot about the onclick being needing to be replaced
with click ,and some other healthy practices like that . but im still
not able to figure out the problem . my click event is not triggered .
no error shown in javascript console as well . any idea ?

// JavaScript Document
window.addEventListener("load", function() {
var i=0;
draw();

function draw(){
var t = document.createElement("div");
t.innerHTML = "<div id=\"div1\" style=\"margin: 0 auto 0
auto;\"><input name=\"submit\" type=\"submit\" id='btnStart'
value=\"Start\"></div>";
document.body.insertBefore(t, document.body.firstChild);
document.getElementById('btnStart').setAttribute(" click",
function()
{start()},false);
}

function start(){
alert('started');
}

},false);

the div1 is shown, but events are not triggered . sometimes i get a
funciton not defined as well.

Keep Clicking,
Bosky

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-04-2006


wrote:


> document.getElementById('btnStart').setAttribute(" click",
> function()
> {start()},false);



I think you want
document.getElementById('btnStart').addEventListen er("click",
function()
{start()},false);

Using setAttribute with a function argument and a third argument does
not make sense with Mozilla/Firefox and Greasemonkey scripts.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
Rob Williscroft
Guest
Posts: n/a
 
      06-04-2006
wrote in news: oups.com in
comp.lang.javascript:

> alright ive heard a lot about the onclick being needing to be replaced
> with click


[snip]

> document.getElementById('btnStart').setAttribute(" click",
> function()
> {start()},false);



document.getElementById('btnStart').addEventListen er(
"click",
function() {start()},
false
);

The event is called "click" the attribute is called "onclick".

Either of:

document.getElementById('btnStart').onclick = function() {start()};
document.getElementById('btnStart').setAttribute(
"onclick",
"alert('started');"
);

Will also work.

> }
>
> function start(){
> alert('started');
> }
>
> },false);
>


Rob.
--
http://www.victim-prime.dsl.pipex.com/
 
Reply With Quote
 
bosky101@gmail.com
Guest
Posts: n/a
 
      06-04-2006

>> thanks guys ...


now ive come across one more problem .the dreaded 'permissions' denial
..

i have the folowing two lines appended in prefs.js:
user_pref("capability.principal.codebase.p0.grante d",
"UniversalBrowserRead");
user_pref("signed.applets.codebase_principal_suppo rt", true);

the ajax calls in my greasemonkey code goes as follows :

if (window.XMLHttpRequest)
{ //FF
setSecurity();
req = new XMLHttpRequest();
[snip]
..
..
..

[/snip]
setSecurity();
req.open("GET", dest, true);
[snip/]

function setSecurity(){
try {
netscape.security.PrivilegeManager.enablePrivilege ("UniversalBrowserRead");
netscape.security.PrivilegeManager.enablePrivilege ("UniversalBrowserWrite");
}
catch (e) {
alert('Permission UniversalBrowserRead denied.');
}
}

now when i embed this code in html it works well. i still get the
Permission UniversalBrowserRead denied. message (exception caught) .
where am i going wrong ?

Thanks again ...
- Bhasker

 
Reply With Quote
 
bosky101@gmail.com
Guest
Posts: n/a
 
      06-04-2006
1) actaully i seem to be getting a 'netscape is not defined' message in
my exception. bugzilla.mozilla.org/show_bug.cgi?id=35116 says that
changing prefs.js ,and then restarting firefox will give the 'netscape
is not defined' message. but i kept restarting FF . still no luck.

2)searching on the 'right' methods to apply privileges in firefox (
without signing ),i came across
http://almaer.com/blog/archives/cat_tech.html that says that :

function securePrivilege(priv) {
// insert the try/catch code from above, plus anything for the
other browsers
}

and then calling securePrivilege('UniversalBrowserRead') WILL NOT WORK
at all !... the privilege that you secure, is only applied in that
scope. This means that the priviledge is only even around INSIDE
securePrivilege(priv), and is thus useless " .... IS this true ?

2) does that mean that the FOLLOWING also will not work since its in a
if/else scope?! :

if (typeof netscape != 'undefined' && typeof netscape.security
!='undefined') {
try
{
netscape.security.PrivilegeManager.enablePrivilege ('UniversalBrowserRead');}catch(e){alert(e.message );}
}

else{ alert(e.message);}
req.open("GET", dest, true);
..
..

3) i also tried avoiding the priveleges line ,and simply depending on
appending a user_pref("signed.applets.codebase_principal_suppo rt",
true); in prefs.js . it STILL dint work .

4)most of the tutorials and guides give incomplete implementations and
just say add a line ,and presto! it shud work . does anyone have a
working example including the xmlhttprequest calls ,and WHERE EXACTLY
to call the privilege setting lines ?

Keep Clicking,
bosky

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Irregularities in Regular Expressions Brantley Harris Javascript 1 08-20-2009 07:43 AM
Greasemonkey security hole Z Firefox 1 07-23-2005 08:40 AM
Fix broken pages (eg: beta-groups) with greasemonkey or related css/XPI? SpamCan Firefox 1 06-01-2005 07:24 AM
Nikon Coolpix 4200 Timestamp Irregularities Top Spin Digital Photography 5 01-07-2005 03:24 PM
boot up irregularities Ronald Smyth Computer Security 0 05-20-2004 05:51 PM



Advertisments
 



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