<?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>Developer Oracles &#187; JavaScript</title>
	<atom:link href="http://devoracles.com/category/development/javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://devoracles.com</link>
	<description></description>
	<lastBuildDate>Sun, 21 Mar 2010 11:05:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>DefiThis un-minified Javascript and code explanation</title>
		<link>http://devoracles.com/defithis-un-minified-javascript-and-code-explanation/883</link>
		<comments>http://devoracles.com/defithis-un-minified-javascript-and-code-explanation/883#comments</comments>
		<pubDate>Sat, 31 Jan 2009 10:16:34 +0000</pubDate>
		<dc:creator>Gary Illyes</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[defithis]]></category>

		<guid isPermaLink="false">http://devoracles.com/?p=883</guid>
		<description><![CDATA[We published a while ago a small WordPress plugin which enables the users to look up words in a specific database, by highlighting with the mouse the word they want to look up then following a link to an administrator set online database (like Google Definition service or Dictionary.com) which will do the rest of [...]]]></description>
			<content:encoded><![CDATA[<p>We published a while ago a small WordPress plugin which enables the users to look up words in a specific database, by highlighting with the mouse the word they want to look up then following a link to an administrator set online database (like Google Definition service or Dictionary.com) which will do the rest of the job.</p>
<p>Worthless to say that this plugin is based on JavaScript in almost 80%, the rest is a bit of PHP which hooks the Javascript code to the WordPress engine and a bit of CSS to style the plugin.</p>
<p>A few words about our coding style: we almost always minify the code made by us. This means that we run a code through a compressor software which strips the unnecessary white spaces and other characters. This applies to both Javascript and CSS. This is not meant to obfuscate the code, but to preserve the bandwidth.<br />
It&#8217;s also good to know that we never use longwinded function names or variables. It&#8217;s likely that you will never see in code released by us function or variable names like:<br />
<code><br />
function this_is_a_cool_function_used_for_nothing(){<br />
}<br />
/*or variable like*/<br />
var this_is_a_useless_variable = '';<br />
</code></p>
<p>Instead, we use function and variable names like this:<br />
<code><br />
function c_D(){<br />
}<br />
/*or variable like*/<br />
var A = '';<br />
</code></p>
<p>The explanation for this habit is that long variable and function names only eats up unnecessary bandwidth, which we don&#8217;t like, and javascript understands both forms of declaration.</p>
<p>If you want to understand the functions we use, you may want to know that each function name is an abbreviation. For example the <code>R_D()</code> function is used for <strong>R</strong>endering <strong>D</strong>efithis, the <code>c()</code> function is used for <strong>C</strong>entering the widget, <code>aph()</code> for fixing <strong>A</strong>l<strong>ph</strong>a transparency in Internet Explorer, and so on.</p>
<p>So, as requested by <a href="http://devoracles.com/wp-plug-defithis#comment-915">Fernando Ramirez</a>, here&#8217;s the unminified javascript code from Defithis. Unobfuscated version does not exist since we believe it&#8217;s not obfuscated. Follow this link to the script: <a rel="nofollow" href="http://devoracles.com/examples/defithis.js">http://devoracles.com/examples/defithis.js</a></p>
<p>If you need explanation regarding anything from within the code, feel free to ask. We listen and will answer.</p>
]]></content:encoded>
			<wfw:commentRss>http://devoracles.com/defithis-un-minified-javascript-and-code-explanation/883/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The best method to check for Internet Explorer in Javascript</title>
		<link>http://devoracles.com/the-best-method-to-check-for-internet-explorer-in-javascript/782</link>
		<comments>http://devoracles.com/the-best-method-to-check-for-internet-explorer-in-javascript/782#comments</comments>
		<pubDate>Thu, 08 Jan 2009 10:59:09 +0000</pubDate>
		<dc:creator>Gary Illyes</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://devoracles.com/?p=782</guid>
		<description><![CDATA[If you will code in Javascript, or if you already familiarized yourself with it, you encounter many times problems related to the fact that Internet Explorer doesn&#8217;t understand a lot of functions which the other browsers can. But the browser market-share dictates that we still have to code in the way to make the script [...]]]></description>
			<content:encoded><![CDATA[<p>If you will code in Javascript, or if you already familiarized yourself with it, you encounter many times problems related to the fact that Internet Explorer doesn&#8217;t understand a lot of functions which the other browsers can. But the browser market-share dictates that we still have to code in the way to make the script work on Internet Explorer, too.</p>
<p>This meant, many invented small, or relatively small functions to detect the user&#8217;s browser. Many times the function is a dozen of lines long, and it&#8217;s called every time the script needs to know whether the user&#8217;s browser is Internet Explorer or other modern browser.</p>
<p>But there&#8217;s a way better way. Better said the simplest way possible. Here it is:</p>
<p><code>var IE = /*@cc_on!@*/false;</code></p>
<p>I guess that needs a bit of explanation, right?<br />
What we see up there? I declared a new variable, called IE, which has the value a comment block followed by &#8216;<em>false</em>&#8216;.<br />
The above variable will be understood by IE: <code>var IE = !false</code>, because Internet Explorer uses JScript &#8212; a Javascript-like dialect of the standard ECMAScript &#8212; instead of Javascript which is used by all the other browsers. JScript can parse the comments, just like Internet Explorer (see <a href="http://devoracles.com/conditions-in-html/367">conditional HTML comments post</a>). This is a unique feature of IE, none of the other browsers can do it, so Firefox, Chrome, Safari, Opera, all will understand the above declaration as <code>IE = false</code>.</p>
<p>How to use this in your codes? Put the above code in the first line of your script, then when you need to know whether the browser is Internet Explorer or not, use conditions, like this:<br />
<code><br />
if(IE){<br />
//IE specific code goes here<br />
}else{<br />
//code for all the other browsers<br />
}<br />
</code></p>
<p>Hope this helps you as it helped me many times.</p>
]]></content:encoded>
			<wfw:commentRss>http://devoracles.com/the-best-method-to-check-for-internet-explorer-in-javascript/782/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>jQuery : Error: $(document).ready is not a function &#8212; Sure!</title>
		<link>http://devoracles.com/jquery-error-documentready-is-not-a-function-sure/446</link>
		<comments>http://devoracles.com/jquery-error-documentready-is-not-a-function-sure/446#comments</comments>
		<pubDate>Sun, 19 Oct 2008 19:17:20 +0000</pubDate>
		<dc:creator>Gary Illyes</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lightbox]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[thickbox]]></category>

		<guid isPermaLink="false">http://devoracles.com/?p=446</guid>
		<description><![CDATA[This error message appears only if another framework is in conflict with the almighty jQuery. For example You try to use Prototype/Scriptaculous for Lightbox but you also need Thickbox for something else, which requires jQuery.
Since no framework is compatible with another framework, you have to find a workaround to get things working.
And here comes jQuery [...]]]></description>
			<content:encoded><![CDATA[<p>This error message appears only if another framework is in conflict with the almighty jQuery. For example You try to use Prototype/Scriptaculous for Lightbox but you also need Thickbox for something else, which requires jQuery.</p>
<p>Since no framework is compatible with another framework, you have to find a workaround to get things working.</p>
<p>And here comes jQuery in your help. The jQuery team was smart enough to realize that there will be conflicts between frameworks, especially the <strong>$</strong> will cause massive headaches since it&#8217;s the basic of each framework. $ is the shortcut for the word &#8220;jQuery&#8221;</p>
<p>So, they invented  <strong>jQuery.noConflict();</strong>. This will let you to replace the $ with the word jQuery, in all your code. So, when you need to call this:  $(document).ready(function(){ &#8230; You simply replace the $ as I said above: jQuery(document).ready(function(){ &#8230;, don&#8217;t forget to call jQuery.noConflict(); before this.</p>
<p>So, when you use the noConflict() function, your code should look something like this:</p>
<pre name="code" class="html">
&lt;head&gt;
  <script src="prototype.js"></script>
  <script src="jquery.js"></script>
  <script>
    jQuery.noConflict();
    jQuery(document).ready(function(){
      jQuery('div').stuff();
      //notice, that the $sign has been replaced with the word jQuery
    });
     // And you can use Prototype with $(...)
     $('id').hide();
   </script>
&lt;/head&gt;
</pre>
<p>World saved again, now you can use 2 frameworks together.</p>
]]></content:encoded>
			<wfw:commentRss>http://devoracles.com/jquery-error-documentready-is-not-a-function-sure/446/feed</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>XHTML Strict incompatible with target attribute: FALSE</title>
		<link>http://devoracles.com/xhtml-strict-incompatible-with-target-attribute-false/251</link>
		<comments>http://devoracles.com/xhtml-strict-incompatible-with-target-attribute-false/251#comments</comments>
		<pubDate>Sun, 21 Sep 2008 10:18:49 +0000</pubDate>
		<dc:creator>Gary Illyes</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://devoracles.com/?p=251</guid>
		<description><![CDATA[





Clients&#8230; I had to create a website&#8230; XHTML Strict&#8230; AND opening all links in a new tab/window.
No probs, there&#8217;s the target attribute of the anchor elements! But not in XHTML Strict!
W3 states clearly that target attributes should be forgotten and avoided. Why, I have no idea, but if you want to create XHTML Strict pages, [...]]]></description>
			<content:encoded><![CDATA[<div style="float: right; margin: 3px;">
<script type="text/javascript"><!--
google_ad_client = "pub-1093600044144676";
/* 250x250, created 9/22/08, Devoracles: Javascript Target */
google_ad_slot = "1352068240";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<p>Clients&#8230; I had to create a website&#8230; XHTML Strict&#8230; AND opening all links in a new tab/window.<br />
No probs, there&#8217;s the target attribute of the anchor elements! But not in XHTML Strict!<br />
W3 states clearly that target attributes should be forgotten and avoided. Why, I have no idea, but if you want to create XHTML Strict pages, you can forget about the target attribute.</p>
<p>So let&#8217;s hack with Javascript this rule! Rules are set to have something to brake, that&#8217;s what we&#8217;ll do now. This is very simple code, basically a single function which loops through the document and adds to all the anchor elements the &#8220;target=&#8217;_blank&#8217;&#8221; attribute. As it&#8217;s created with Javascript, the XHTML validators should not observe. I think they won&#8217;t observe, so first check it out somewhere.</p>
<p>So, the Javascript code to open links in new window/tab while maintaining the XHTML Strict compliance is:</p>
<pre name="code" class="js">
function open_in_new_tab() {
if (!document.getElementsByTagName){
return;
/*If the browser doesn't support DOM, do nothing*/
}
var anchors = document.getElementsByTagName("a");
/*Select all the 'a' tags, anchors*/
for (var i=0; i&lt;anchors.length; i++) {
var links = anchors[i];
if (links.getAttribute("href")){
/*every anchor with 'href' attribute will get a new attribute,
only those with 'href' attribute set because we don't want
to mess with the section anchors, for example*/
links.target = "_blank";
}
}
}
window.onload = open_in_new_tab;
/*finally load the function on page load*/
</pre>
<p>And the word is saved again. </p>
]]></content:encoded>
			<wfw:commentRss>http://devoracles.com/xhtml-strict-incompatible-with-target-attribute-false/251/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript pop-up windows and parent page refreshing</title>
		<link>http://devoracles.com/javascript-pop-up-windows-and-parent-page-refreshing/217</link>
		<comments>http://devoracles.com/javascript-pop-up-windows-and-parent-page-refreshing/217#comments</comments>
		<pubDate>Sat, 20 Sep 2008 16:58:58 +0000</pubDate>
		<dc:creator>Gary Illyes</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[close parent window]]></category>
		<category><![CDATA[javascript close parent window]]></category>
		<category><![CDATA[javascript refresh parent window]]></category>
		<category><![CDATA[javascript window close]]></category>
		<category><![CDATA[javascript window open]]></category>
		<category><![CDATA[javascript window opener reload]]></category>
		<category><![CDATA[javascript window refresh]]></category>
		<category><![CDATA[onclick window open]]></category>
		<category><![CDATA[parent window refresh]]></category>
		<category><![CDATA[popup window]]></category>
		<category><![CDATA[popup window block]]></category>
		<category><![CDATA[popup window javascript]]></category>
		<category><![CDATA[refresh parent window from child window]]></category>
		<category><![CDATA[refreshing parent window]]></category>
		<category><![CDATA[window opener javascript]]></category>
		<category><![CDATA[window opener refresh javascript]]></category>
		<category><![CDATA[window opener reload]]></category>
		<category><![CDATA[window pop up]]></category>

		<guid isPermaLink="false">http://devoracles.com/?p=217</guid>
		<description><![CDATA[This subject is quite interesting and i was searching for examples for long. Then I managed to do something, true that only by combining many examples i&#8217;ve found.
Let&#8217;s see the code then I&#8217;ll try to explain everything.

function popUp(URL) {
window.open(URL, 'WindowName', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=400');
}
window.onload = popUp("http://example.com");

The above function will pop-up window which will contain the page you put [...]]]></description>
			<content:encoded><![CDATA[<p>This subject is quite interesting and i was searching for examples for long. Then I managed to do something, true that only by combining many examples i&#8217;ve found.</p>
<p>Let&#8217;s see the code then I&#8217;ll try to explain everything.</p>
<pre name="code" class="js">
function popUp(URL) {
window.open(URL, 'WindowName', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=300,height=400');
}
window.onload = popUp("http://example.com");
</pre>
<p>The above function will pop-up window which will contain the page you put as value in the popUp function. I&#8217;ve put http://example.com, you put whatever you like, but preferably from your own domain if you want to have access to the pop-up&#8217;s DOM. You can play with the toolbar,scrollbars,location variables till hurts, basically they define how the popped up window will look and act. I wrote the above script so to pop the window up when the page loads (<i>window.onload</i>) , if you don&#8217;t like that and the fact that this even is blocked by most pop-up blockers, you can put a HTML button or link somewhere in the page, like this:</p>
<pre name="code" class="html">
<form>
<input type=button value="pop this up" onClick="popUp('http://example.com')">
</form>

<!-- or a link -->
<a href="#" onclick="popUp('http://example.com')">Pop Up the window</a>
</pre>
<p>As I said before, there&#8217;s a slight issue with the stuff if you use the window.onload, specifically that your pop-up much likely will be blocked by pop-up blockers. You don&#8217;t want that, and even if it succeeds to pop-up, it&#8217;s annoying for the visitor, so just don&#8217;t do it, please.</p>
<p>OK, now let&#8217;s see the the parent window refreshing. Prent window is the page which pop-up up the small window. The pop-up window is the child. Usually, we use the parent refresh if we want to transfer a variable from the pop-up to the parent. The script which has to be placed in the child, popped up window is the following script:</p>
<pre name="code" class="js">
function Parent() {
  window.opener.location.href = window.opener.location.href;
  if (window.opener.progressWindow){
    window.opener.progressWindow.close()
  }
  window.close();
}
</pre>
<p>and the button or link which closes and refreshes the parent window is </p>
<pre class="html" name="code">
<a href="#" onclick="Parent()">Click here to close this window and refresh the parent</a>
<!-- or the button -->
<form>
<input type="button" value="Click here to close this window and refresh the parent" onclick="Parent()" />
</form>
</pre>
<p>A working example is situated <a href="http://tester.devoracles.com/pop_up_1.html" rel="noindex, nofollow">here</a>. It&#8217;s a loop so if your pop-up blocker doesn&#8217;t block the first pop-up, most likely you&#8217;ll get annoyed in no time.</p>
<p>And I think that was all. You can also transfer variables from one window to other, but that&#8217;s for another day&#8230; so, the show is over&#8230; there&#8217;s nothing to see here, pass over please.</p>
]]></content:encoded>
			<wfw:commentRss>http://devoracles.com/javascript-pop-up-windows-and-parent-page-refreshing/217/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
