Add to and" /> " /> Password <br /><input type="password" name="passwd" id="passwd" class="inputbox" size="18" alt="password" />
Home The JavaScript language Questions for JavaScripts
PDF

Add page to favorites

1
<a rel="sidebar" onclick="window.external.AddFavorite(location.href,'Мой сайт!'); return false;" href="http://somesite.com/" title="Мой сайт!">Добавить в избранное</a>

The value in the input

1
<input type="text" size="35" value="поиск..."  onblur="if(this.value=='') this.value='поиск...';" onfocus="if(this.value=='поиск...') this.value='';" />

Just move

1
2
3
<script type="text/javascript"> 
window.location="";
</script>

To move his legs back.

 

1
<a href="javascript:history.go(-1)">вернуться</a>

To serve as a delay.

1
2
3
setTimeout( function() {
// код
}, 600);

We treat the background image to flicker in IE

1
2
3
body{
filter: expression(document.execCommand("BackgroundImageCache", false, true));
}

Set the min-width and max-width in IE6

1
2
3
4
5
6
#container 
{
min-width: 600px;
max-width: 1200px;
width:expression(document.body.clientWidth < 600? "600px" : document.body.clientWidth > 1200? "1200px" : "auto");
}

Example of looping functions in JavaScript

1
2
3
4
5
6
7
8
function DoRefresh() {
alert(1);
Refresh();
}
function Refresh(){
timeid=setTimeout('DoRefresh()', 10 * 1000);
}
Refresh();

Check the existence of an element on the page.

1
2
3
if($("#maincolumn").length!=0) {
// код
}

textarea.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
  n - позиция в которую нужно переместить указатель. Цифра.
  o - объект
*/
function goTo(n, o) {
if (!document.all) {
var end = o.value.length;
o.setSelectionRange(n, n);
o.focus();
}
else {
var r = o.createTextRange();
r.collapse(true);
r.moveStart("character", n);
r.moveEnd("character", 0);
r.select();
}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
  obj - объект
*/
function getCaretPos(obj) {
obj.focus();
 
if (obj.selectionStart) return obj.selectionStart; //Gecko
else if (document.selection) //IE
{
var sel = document.selection.createRange();
var clone = sel.duplicate();
sel.collapse(true);
clone.moveToElementText(obj);
clone.setEndPoint('EndToEnd', sel);
return clone.text.length;
 

Comments

 
0 #1 koma 2011-03-31 03:58 Hi. Interesting script.
Only justified in "Just transition"
window.location="";
Quote
 
 
0 #2 Евгений Т. 2011-06-24 15:13 Example stalled javascript functions
Why so hard?)) Is sufficient:

function DoRefresh(){
alert (1);
}

timeid = setInterval ('DoRefresh ()', 10 * 1000);
Quote
 

Authorization

Nice Ajax Poll

Which one of my extensions is the best?

Statistics

Advertisement