<?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"
	>

<channel>
	<title>Just answer the F*#king question &#187; Javascript</title>
	<atom:link href="http://www.jatfq.com/archives/category/usefull-stuff/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jatfq.com</link>
	<description>Saving the world from dicks with forum logins ...</description>
	<pubDate>Mon, 03 Nov 2008 17:18:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Delete a tag in Javascript</title>
		<link>http://www.jatfq.com/archives/58</link>
		<comments>http://www.jatfq.com/archives/58#comments</comments>
		<pubDate>Thu, 09 Oct 2008 19:42:04 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/?p=58</guid>
		<description><![CDATA[I use with with AJAX library to completely remove a DIV tag ( or whatever )

function removeTag(tag){
	field = document.getElementById(tag);
	field.parentNode.removeChild(field);
}
function removeAllChildren(field){
	 if ( field.hasChildNodes() )
	 {
    	while ( field.childNodes.length >= 1 )
	    {
			removeAllChildren(field.firstChild);
	   	    field.removeChild(field.firstChild);
	    }
	}
}










]]></description>
			<content:encoded><![CDATA[<p>I use with with AJAX library to completely remove a DIV tag ( or whatever )</p>
<p><code><br />
function removeTag(tag){<br />
	field = document.getElementById(tag);<br />
	field.parentNode.removeChild(field);<br />
}</p>
<p>function removeAllChildren(field){<br />
	 if ( field.hasChildNodes() )<br />
	 {<br />
    	while ( field.childNodes.length >= 1 )<br />
	    {<br />
			removeAllChildren(field.firstChild);<br />
	   	    field.removeChild(field.firstChild);<br />
	    }<br />
	}<br />
}<br />
</code></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F58&amp;title=Delete+a+tag+in+Javascript" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F58&amp;title=Delete+a+tag+in+Javascript" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F58&amp;title=Delete+a+tag+in+Javascript" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F58&amp;title=Delete+a+tag+in+Javascript" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F58&amp;title=Delete+a+tag+in+Javascript', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F58" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F58&amp;title=Delete+a+tag+in+Javascript" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F58&amp;title=Delete+a+tag+in+Javascript" title="Stumble it!"><img src="/icon_stumbleupon.gif" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/58/feed</wfw:commentRss>
		</item>
		<item>
		<title>Ajax wrapper class</title>
		<link>http://www.jatfq.com/archives/23</link>
		<comments>http://www.jatfq.com/archives/23#comments</comments>
		<pubDate>Tue, 22 Apr 2008 22:22:02 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/archives/23</guid>
		<description><![CDATA[I&#8217;m not really a big fan of &#8220;AJAX&#8221; ( yes, I put it in quotes ). To be honest, I&#8217;ve being doing AJAX type stuff since the dawn of Javscript and IFRAMES, but now it has a name and everyone is using it. My pet hate is AJAX for the sake of AJAX, reloading 5mb [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not really a big fan of &#8220;AJAX&#8221; ( yes, I put it in quotes ). To be honest, I&#8217;ve being doing AJAX type stuff since the dawn of Javscript and IFRAMES, but now it has a name and everyone is using it. My pet hate is AJAX for the sake of AJAX, reloading 5mb of data when a simple page refresh will do.</p>
<p>Saying all that, what AJAX I do now, I do with this great wrapper class</p>
<p><a href="http://www.cmarshall.net/MySoftware/ajax/">http://www.cmarshall.net/MySoftware/ajax/</a></p>
<p>Works like a charm and really simple to impliment. If I get the time, I&#8217;ll add in some very simple PHP examples on how to make re-usable AJAX type code for populating lists etc.</p>
<p><a href="http://tools.web-max.ca/websitesonip.php?domain=cmarshall&#038;bydomain=1">[-]</a></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F23&amp;title=Ajax+wrapper+class" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F23&amp;title=Ajax+wrapper+class" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F23&amp;title=Ajax+wrapper+class" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F23&amp;title=Ajax+wrapper+class" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F23&amp;title=Ajax+wrapper+class', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F23" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F23&amp;title=Ajax+wrapper+class" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F23&amp;title=Ajax+wrapper+class" title="Stumble it!"><img src="/icon_stumbleupon.gif" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/23/feed</wfw:commentRss>
		</item>
		<item>
		<title>Handling bookmarks / named anchors in an IFRAME</title>
		<link>http://www.jatfq.com/archives/21</link>
		<comments>http://www.jatfq.com/archives/21#comments</comments>
		<pubDate>Thu, 14 Feb 2008 22:48:30 +0000</pubDate>
		<dc:creator>Sime</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.jatfq.com/archives/21</guid>
		<description><![CDATA[So, you are using IFRAMES, good on you. You have a nice document with lots of names anchors, but you find when you click on the bookmark link, the whole window, parent and all, scrolls into view. Pain in the ass. To get around it, use Javascript as such &#8230;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function findPosY&#40;obj&#41;
&#123;
  var curtop = [...]]]></description>
			<content:encoded><![CDATA[<p>So, you are using IFRAMES, good on you. You have a nice document with lots of names anchors, but you find when you click on the bookmark link, the whole window, parent and all, scrolls into view. Pain in the ass. To get around it, use Javascript as such &#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> findPosY<span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> curtop = <span style="color: #CC0000;">0</span>;
  <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>obj.<span style="color: #006600;">offsetParent</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #000066; font-weight: bold;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        curtop += obj.<span style="color: #006600;">offsetTop</span>;
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>!obj.<span style="color: #006600;">offsetParent</span><span style="color: #66cc66;">&#41;</span><span style="color: #000066; font-weight: bold;">break</span>;
        obj = obj.<span style="color: #006600;">offsetParent</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>obj.<span style="color: #006600;">y</span><span style="color: #66cc66;">&#41;</span>
    curtop += obj.<span style="color: #006600;">y</span>;
  <span style="color: #000066; font-weight: bold;">return</span> curtop;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> <span style="color: #000066;">scroll</span><span style="color: #66cc66;">&#40;</span>element<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
  p = findPosY<span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span>element<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  window.<span style="color: #006600;">scrollBy</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">0</span>,p<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>The findPosY is not my code, sorry, cant remember the original author - if I find you I will credit you.</p>
<p>In your HTML use<br />
<code><br />
&lt;a href="javascript:scroll('A');">A</a><br />
</code><br />
and for the named anchor use any tag and add the ID for the link, ie<br />
<code><br />
&lt;h3 id="A">A</h3>
<p></code></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F21&amp;title=Handling+bookmarks+%2F+named+anchors+in+an+IFRAME" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F21&amp;title=Handling+bookmarks+%2F+named+anchors+in+an+IFRAME" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F21&amp;title=Handling+bookmarks+%2F+named+anchors+in+an+IFRAME" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F21&amp;title=Handling+bookmarks+%2F+named+anchors+in+an+IFRAME" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F21&amp;title=Handling+bookmarks+%2F+named+anchors+in+an+IFRAME', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F21" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F21&amp;title=Handling+bookmarks+%2F+named+anchors+in+an+IFRAME" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.jatfq.com%2Farchives%2F21&amp;title=Handling+bookmarks+%2F+named+anchors+in+an+IFRAME" title="Stumble it!"><img src="/icon_stumbleupon.gif" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://www.jatfq.com/archives/21/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
