This page (revision-6) was last changed on 02-May-2017 19:30 by Dieter Käppel

This page was created on 07-Sep-2012 07:44 by Dieter Käppel

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
6 02-May-2017 19:30 2 KB Dieter Käppel to previous
5 02-May-2017 19:30 2 KB Dieter Käppel to previous | to last
4 13-Jun-2016 15:22 1 KB Dieter Käppel to previous | to last
3 12-Dec-2012 10:14 1 KB Dieter Käppel to previous | to last
2 24-Sep-2012 07:44 948 bytes Dieter Käppel to previous | to last
1 07-Sep-2012 07:44 547 bytes Dieter Käppel to last

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 37 removed 59 lines
!!!Dynamische Header
Folgender Code fügt neue Header ein:
{{{
function addHeader(text) {
var head = document.getElementsByTagName("head")[0];
var div = document.createElement('div');
div.innerHTML = text;
for (var i = 0; i < div.childNodes.length; ++i) {
var element = document.createElement(div.childNodes[i].nodeName);
element.innerHTML = div.childNodes[i].innerHTML;
for (var j = 0; j < div.childNodes[i].attributes.length; ++j) {
element.setAttribute(
div.childNodes[i].attributes[j].name, div.childNodes[i].attributes[j].value);
}
head.appendChild(element);
}
}
}}}
!!!Property Interceptor
Mit Object.defineProperty kann man einen Interceptor für Getter und Setter einfügen:
{{{
var scrollTop = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(HTMLElement.prototype), "scrollTop");
Object.defineProperty(HTMLElement.prototype, "scrollTop", {
get: function() {
return scrollTop.get.apply(this, arguments);
},
set: function() {
return scrollTop.set.apply(this, arguments);
}
});
}}}
!!!Lambda Function
Mit dieser Funktion können anonyme, rekursive Funktionen definiert werden:
{{{
var Y = function(f) {
return (function(g) {
return g(g);
})(function(h) {
return function() {
return f.apply(h(h), arguments);
};
});
};
}}}
Eine rekursive Funktion sieht dann wie folgt aus (Fakultät, aufgerufen mit Wert 5):
{{{
Y(function(n) {return n == 0 ? 1 : n * this(n - 1);})(5);
}}}
!!!Links
* [Funktionen|http://www.howtocreate.co.uk/tutorials/javascript/functions]