Entries Tagged as 'Javascript'
Here’s a quick way to disable selection on browsers using Javascript. Helpful if you don’t want somebody to select a bunch of text and copy and paste.
1
2
3
4
5
6
7
8
9
10
11
12
13
window.onload = function() {
disableSelection(document.body)
}
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox
target.style.MozUserSelect="none"
else //All other ie: Opera
target.onmousedown=function(){return false}
target.style.cursor = "default"
}
[Read more →]
Tags:disable select·disable selection·Javascript
Here’s a really quick way to add a button into an existing page and then have the button call a function that is within greasemonkey script.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
window.addEventListener("load", function(e) {
addButton();
}, false);
function addButton(){
var buttonElems = document.getElementsByTagName(’buttonElementName’);
buttonElems[0].innerHTML = buttonElems[0].innerHTML + ‘<input id="greasemonkeyButton" type="button" value="Call Greasemonkey Function" />’
addButtonListener();
}
function addButtonListener(){
var button = document.getElementById("greasemonkeyButton");
button.addEventListener(’click’,doMonkey,true);
}
function [...]
[Read more →]
Tags:button·function·greasemonkey·Javascript·onclick
JavaScript provides setTimeout(), clearTimeout() , setInterval() and clearInterval() for your javascript timer functions which allows you to run a piece of Javascript code at some point in the future. Here are some explanation of the functions.
setTimeout ( expression, timeout );
setTimeout() returns a numeric timeout ID that can be used to track the timeout. This is [...]
[Read more →]
Tags:cleartimeout method·javascript timer·setinterval method·settimeout method·timer functions