Browser-History mit jQuery auslesen

Eine wirklich simple Idee … mittels der Farbunterscheidung zwischen “visited”- bzw. “nicht visited”-Links kann man die Browser-History eines Benutzers stehlen. Man braucht allerdings eine Linkliste die man vergleichen kann, also ist es kein richtiges stehlen. Im Detail funktioniert es so das man mittels Javascript Links erzeugt und vergleicht in welcher Farbe sie dargestellt werden. So kann man zB feststellen ob der Benutzer vorher schon bei den Konkurrenten vorbeigeschaut hat.

Mein Beispiel-Script kann man unter folgender Adresse finden:
http://bohuco.net/dev/history/

(via dicabrio)

February 2, 2010

Google Closure Compiler with PHP

Today Google released their new Closure Compiler, you can use it to optimize and minify your javascripts.

November 7, 2009

iPhone Lagesensor via Javascript

Über den Lagesensor kann man ermitteln ob das iPhone gerade hochkant oder horizontal gehalten wird. Safari am iPhone besitzt dazu ein spezielles window-attribut. In window.orientation steht entweder 0 (für vertikal) oder +/-90 wenn das iPhone quer gehalten wird, je nachdem welche Richtung es gedreht wurde.

Um auf eine Änderung reagieren zu können gibt es den Event-Handler onorientationchange den man zum Beispiel im BODY-Tag verwenden kann:

 
    <body onorientationchange="alert(window.orientation);"></body>

» Beispiel-Seite

July 14, 2009

Chrome Javascript Debugger/Profiler

Google hat diese Woche einen Javascript Debugger/Profiler für Chrome veröffentlicht, bisher waren ja nur die WebKit-Tools enthalten.

via golem

June 27, 2009

Firebug console.log – graceful degradation and cool features

My favorite feature in firebug is console.log but it has one problem, you have to remove all calls from source code before going live else your visitors will get many many javascript errors. But there is a really simple solution for that problem, getfirebug.com hosts a javascript which creates a fallback console object if firebug is not installed.

[sourcecode language="javascript"]


[/sourcecode]

So, now we are on the save side and can play around with the console object. The usually most used method is “log”, it simply prints something to the console. Strings, Arrays, Objects, Dom, XML … everything works, log can also print more than one variable at once.

[sourcecode language="javascript"]

console.log(‘A String’, ['an','array'], document.getElementById(‘domObject’));

[/sourcecode]

Console can write messages with a specific type, so you can print errors and warnings to your console.

[sourcecode language="javascript"]

console.error(‘an error’);
console.warn(‘a warning’);

[/sourcecode]

Outline object members in console with the ‘dir’ method.

[sourcecode language="javascript"]

console.dir({nice:’to’, see:’that’, cool:function(){ alert(‘cool’); }});

[/sourcecode]

If you wanna see all cool features, now and live, there is an example page on bohuco.net/code:
http://bohuco.net/code/firebug-logging/

More infos:
http://getfirebug.com/console.html
Google Code – Fun with Firebug

February 2, 2009

Playing around with gameQuery

gameQuery, a new jQuery plugin, provides functions for creating browser games. In this early stage gameQuery supports a main-loop, game area (playground), sprites with CSS animations and sounds (not tried yet).

I have played around with gameQuery and here is the result. A simple Pong clone that should work in IE6/7, Chrome and Firefox.

The current gameQuery version is 0.2.5 and so there are some points for improvement. Every sprite needs an animation and every animation needs an image even if you don’t need it. Playground is always position:absolute and it has a black border. Only little things that you can override.

found @ Ajaxian

October 12, 2008

Javascript private members

Die definitive Link-Sammlung:

http://www.crockford.com/javascript/private.html

http://mckoss.com/jscript/object.htm

Wichtig: Private Variablen können nicht aus den public Methoden gelesen werden sondern nur aus den private-Methoden … also MUSS es für die privaten Variablen Setter- und Getter-Methoden geben. Und, die privaten Methoden werden NICHT mit “this” aufgerufen:

[sourcecode language='javascript']

var test = function() {

// private variable
var status = 1;

// private method
var getStatus = function() {
return status;
}

return {
publicMethod: function() {
var status = getStatus(); // NOT this.getStatus();
}
}
}

[/sourcecode]

October 11, 2008

Schrift-Problem adee

facelift (FLIR) ist ein Javascript/PHP-Lösung die on-the-fly Bilder mit Schriftzügen in den gewünschten Schriften erzeugt. FLIR benötigt im Gegensatz zu sIFR, kein Flash. Die Bilder werden serverseitig mittels PHP (GD-Library) erzeugt und dann automatisch in die Seite eingefügt.

Tutorial

August 11, 2008

IE6 PNG Fix

Beim CSSGirl wird ein neuer PNG Fix vorgestellt, ich werd ihn nicht gleich ausprobieren aber er scheint wohl besser zu sein als das was es bisher gegeben hat. Es wird SuperSlight mit dem neuen Unit PNG Fix verglichen und jeder hat seine Vor- und Nachteile aber der Unit PNG Fix hat dann doch die Nase vorn.

August 11, 2008

Firebug Plugins

Firecookie – Lässig, alle aktuellen Cookies einfach in einem Firebug-Tab bearbeiten.

FirePHP – PHP Debug-Messages und Exceptions in Firebug anzeigen.

found@walsh, direct

July 27, 2008