<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>monkey-business.biz &#187; Javascript</title> <atom:link href="http://www.monkey-business.biz/tag/javascript/feed/" rel="self" type="application/rss+xml" /><link>http://www.monkey-business.biz</link> <description>Belästigung der Allgemeinheit - mein privater Weblog</description> <lastBuildDate>Wed, 30 Jun 2010 20:45:06 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>daily</sy:updatePeriod> <sy:updateFrequency>4</sy:updateFrequency> <item><title>Javascript: prüfen ob ein Element existiert</title><link>http://www.monkey-business.biz/672/javascript-prufen-ob-ein-element-existiert/</link> <comments>http://www.monkey-business.biz/672/javascript-prufen-ob-ein-element-existiert/#comments</comments> <pubDate>Thu, 25 Feb 2010 15:48:09 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Entwicklung]]></category> <category><![CDATA[Javascript]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=672</guid> <description><![CDATA[Da die Statistik sehr viele Suchanfragen nach dem oben betitelten Thema verzeichnet, habe ich mich entschlossen darüber zu schreiben. Allgemein ist &#8220;Javascript: prüfen ob ein Element existiert&#8221; ein gutes Google Thema. In Javascript ist das prüfen ob ein Element existiert bzw. vorhanden ist ebenso einfach wie in jQuery. Zum Javascriptcode: if &#40;document.getElementById&#40;'divname'&#41;&#41; &#123; // Code [...]]]></description> <content:encoded><![CDATA[<p>Da die Statistik sehr viele Suchanfragen nach dem oben betitelten Thema verzeichnet, habe ich mich entschlossen darüber zu schreiben. Allgemein ist &#8220;Javascript: prüfen ob ein Element existiert&#8221; ein gutes Google Thema. In Javascript ist das prüfen ob ein Element existiert bzw. vorhanden ist ebenso einfach wie in <a href="/119/jquery-prufen-ob-ein-element-existiert/" title="jQuery: prüfen ob ein Element existiert">jQuery</a>. Zum Javascriptcode:</p><div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'divname'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Code ausführen, wenn DIV Element vorhanden. Funktioniert!</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>Der Selektor ist in purem Javascript auf die div id beschränkt. Sehr ärgerlich ist das hierbei keine Klassen selektiert werden können. <a href="/119/jquery-prufen-ob-ein-element-existiert/" title="jQuery: prüfen ob ein Element existiert">jQuery</a> bietet diese Möglichkeit.</p> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/672/javascript-prufen-ob-ein-element-existiert/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>jQuery Interfaces Fisheye position: fixed; Patch</title><link>http://www.monkey-business.biz/181/jquery-interfaces-fisheye-position-fixed-patch/</link> <comments>http://www.monkey-business.biz/181/jquery-interfaces-fisheye-position-fixed-patch/#comments</comments> <pubDate>Mon, 04 Jan 2010 20:20:43 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Fisheye]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[Patch]]></category> <category><![CDATA[position: fixed;]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=181</guid> <description><![CDATA[(to the english part of the post)Dir wird in diesem Artikel der neue jQuery Interfaces Fisheye position: fixed; Patch zum herunterladen angeboten. Mit diesem Patch funktioniert das Fisheye auch nach dem Scrollen bei fixer Positionierung. Die Vorgehensweise ist denkbar einfach. Es muss nur der Patch nach der jQuery interfaces Datei eingebunden werden. Ein Beispiel folgt. [...]]]></description> <content:encoded><![CDATA[<p><a href="#jquery-interfaces-fisheye-position-fixed-patch_english">(to the english part of the post)</a><a name="jquery-interfaces-fisheye-position-fixed-patch_deutsch"></a><br />Dir wird in diesem Artikel der neue jQuery Interfaces Fisheye position: fixed; Patch zum herunterladen angeboten. Mit diesem Patch funktioniert das Fisheye auch nach dem Scrollen bei fixer Positionierung. Die Vorgehensweise ist denkbar einfach. Es muss nur der Patch nach der jQuery interfaces Datei eingebunden werden. Ein Beispiel folgt.</p><div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!--- jQuery Framework einbinden ---&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;interface.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!--- jQuery interfaces Plugin einbinden ---&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fisheye_patched.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!--- hier den Patch einbinden ---&gt;</span></pre></div></div><h3><a href="/wp-content/uploads/2010/01/fisheye_patched.zip" title="Fisheye position: fixed; Patch herunterladen">Fisheye position: fixed; Patch herunterladen</a></h3><p>Zip Datei enthält Javascript Datei.</p><p>Weitere Verweise zum Thema:</p><ul><li><a href="/wp-content/uploads/2010/05/fisheye/index.html" title="Patch Demo" target="_blank">jQuery Interface Fisheye Fix Demo</a></li><li><a href="/wp-content/uploads/2010/02/interfaces.zip">jQuery Interface herunterladen</a></li><li><a href="http://www.ndesign-studio.com/blog/mac/css-dock-menu" target="_blank">jQuery Interface Fisheye Anleitung</a></li></ul><hr /> <a href="#jquery-interfaces-fisheye-position-fixed-patch_deutsch">(Zum deutschen Teil des Artikels)</a><br /> <a name="jquery-interfaces-fisheye-position-fixed-patch_english"></a><p>In this post you will be offered to download the jQuery Interfaces Fisheye position: fixed; patch. With this patch the Fisheye works after scrolling while it&#8217;s fixed positioned. The procedure is simple. You only need to include the patch after including the jQuery inferfaces file. An example follows.</p><div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!--- include jQuery Framework ---&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;interface.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!--- include jQuery interfaces plugin ---&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fisheye_patched.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span> <span style="color: #808080; font-style: italic;">&lt;!---include the patch ---&gt;</span></pre></div></div><h3><a href="/wp-content/uploads/2010/01/fisheye_patched.zip" title="Fisheye position: fixed; patch download">Fisheye position: fixed; patch download</a></h3><p>Zip file includes javascript file.</p><p>More links to this subject:</p><ul><li><a href="/wp-content/uploads/2010/05/fisheye/index.html" title="Fixed demo" target="_blank">jQuery Interface Fisheye fix demo</a></li><li><a href="/wp-content/uploads/2010/02/interfaces.zip">jQuery Interface download</a></li><li><a href="http://www.ndesign-studio.com/blog/mac/css-dock-menu" target="_blank">jQuery Interface Fisheye tutorial</a></li></ul> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/181/jquery-interfaces-fisheye-position-fixed-patch/feed/</wfw:commentRss> <slash:comments>17</slash:comments> </item> <item><title>jQuery: prüfen ob ein Element existiert</title><link>http://www.monkey-business.biz/119/jquery-prufen-ob-ein-element-existiert/</link> <comments>http://www.monkey-business.biz/119/jquery-prufen-ob-ein-element-existiert/#comments</comments> <pubDate>Tue, 22 Dec 2009 18:31:02 +0000</pubDate> <dc:creator>Loaden</dc:creator> <category><![CDATA[Belästigung der Allgemeinheit - mein privater Weblog]]></category> <category><![CDATA[Entwicklung]]></category> <category><![CDATA[Framework]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[jQuery]]></category><guid isPermaLink="false">http://www.monkey-business.biz/?p=119</guid> <description><![CDATA[Ich stand vor kurzem vor dem Problem in Javascript zu prüfen ob ein DIV Element in einem HTML Dokument existiert. Mir stand aus vorangehender Entwicklung das jQuery Framework zur Verfügung. Dabei produzierte ich folgenden Code: if &#40;$&#40;'div#divname'&#41;&#41; &#123; // Code ausführen, wenn DIV Element vorhanden. Funktioniert leider nicht &#125; Das klappte leider nicht, da der [...]]]></description> <content:encoded><![CDATA[<p>Ich stand vor kurzem vor dem Problem in <a href="/672/javascript-prufen-ob-ein-element-existiert/" title="Javascript: prüfen ob ein Element existiert">Javascript zu prüfen ob ein DIV Element</a> in einem HTML Dokument existiert. Mir stand aus vorangehender Entwicklung das jQuery Framework zur Verfügung. Dabei produzierte ich folgenden Code:</p><div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div#divname'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Code ausführen, wenn DIV Element vorhanden. Funktioniert leider nicht</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>Das klappte leider nicht, da der Einsatz der jQuery Selektor Funktion immer ein Objekt zurückliefert. Mir war klar das es sich hierbei um ein leeres Objekt handelt und ich nur auf die Länge prüfen müsste. Sollte die Länge 0 sein ist der DIV im aktuellen Dokument nicht vorhanden. Hier nun der Code mit dem es entgültig klappte:</p><div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div#divname'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">// Code ausführen, wenn DIV Element vorhanden. Funktioniert!</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>Ich verwende &gt; anstatt ==, da diese Methode auch bei CSS Klassen funktioniert und keine Nachteile in der Performance bietet. Klassen können mehrfach im Dokument vorkommen. Deswegen kann die Länge größer als 1 sein.</p><p><a href="http://api.jquery.com/category/selectors/" target="_blank" title="Selektoren - jQuery API">Mehr zum Thema jQuery Selektoren</a></p> ]]></content:encoded> <wfw:commentRss>http://www.monkey-business.biz/119/jquery-prufen-ob-ein-element-existiert/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 5/11 queries in 0.003 seconds using disk

Served from: www.monkey-business.biz @ 2010-07-30 08:20:58 -->