<?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>Aleksandar Vacić &#187; WCH</title>
	<atom:link href="http://aplus.rs/category/wchdev/feed/" rel="self" type="application/rss+xml" />
	<link>http://aplus.rs</link>
	<description>aplus.rs</description>
	<lastBuildDate>Tue, 07 Feb 2012 04:49:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Small bug fix</title>
		<link>http://aplus.rs/wchdev/small-bug-fix/</link>
		<comments>http://aplus.rs/wchdev/small-bug-fix/#comments</comments>
		<pubDate>Mon, 19 Apr 2004 17:07:02 +0000</pubDate>
		<dc:creator>Aleksandar</dc:creator>
				<category><![CDATA[WCH]]></category>

		<guid isPermaLink="false">http://www.aplus.co.yu/?p=61</guid>
		<description><![CDATA[Bug fix concerning the size and placement of the repeatedly called WCH iFrame.]]></description>
			<content:encoded><![CDATA[<p>
Building upon the techniques I <a href="/techs/javascripts-hidden-gems/">wrote about</a>, WCH is recoded in such manner. By itself, this would not warrant an entry, but I also introduced one change.
</p>
<p>
Previously, when you first call <code>WCH.Apply("layer", "cont")</code>, it would create an <code>iFrame</code> with an id of <code>WCHhiderlayer</code>. It will also position the iFrame to be the exact size and at exact position (exact…more or less) as the layer is (minding the positioned container). All fine until now.<br />
<br />
However, if the layer changes its position or size, its corresponding WCH layer will not. I noticed this bug when testing out <a href="/adxmenu/">ADxMenu</a> behavior when window is resized.
</p>
<p>
<code>Apply</code> method now has 3<sup>rd</sup> parameter, <code>bResize</code>. If its value is true, and the iFrame needed already exists, sizing and positioning will be repeated.
</p>
<pre>
this.Apply = function(vLayer, vContainer, <strong>bResize</strong>) {
  ...
  if ( _bIE55 &#038;&#038;
    (oIframe = _Hider(vLayer, vContainer, <strong>bResize</strong>)) ) {
  ...
};
...
function _Hider(vLayer, vContainer, bResize) {
  ...
  if ( !oIframe ) {
    ...<strong>
  } else if (bResize) {
    _SetPos(oIframe, oLayer);
</strong>  }
  ...
};
</pre>
<p>
Now you just need to decide when should this parameter be true.</p>
]]></content:encoded>
			<wfw:commentRss>http://aplus.rs/wchdev/small-bug-fix/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>WCH3. Works in IE5.0+</title>
		<link>http://aplus.rs/wchdev/wch3-works-in-ie50/</link>
		<comments>http://aplus.rs/wchdev/wch3-works-in-ie50/#comments</comments>
		<pubDate>Fri, 26 Mar 2004 11:03:51 +0000</pubDate>
		<dc:creator>Aleksandar</dc:creator>
				<category><![CDATA[WCH]]></category>

		<guid isPermaLink="false">http://www.aplus.co.yu/?p=57</guid>
		<description><![CDATA[WCH has matured. It supports IE5.0+ and it's lighter than ever (5.5kB commented, 2kB compressed).]]></description>
			<content:encoded><![CDATA[<p>
I have to stop giving definitive sentences. I just decided recently that I’m gonna develop two version of WCH2, and than <a href="http://www.infosauce.com/">Tim Connor</a> spoils it all and hands the idea of short and sweet way of covering IE5.01, without too much code. Oh well. :)<br />
<br />
So, now I have 3rd generation of WCH, which covers IE5.0 and later. Also, I took the opportunity to rewrite the script the same way as ADxMenu. WCH is now an object, and you simply call its methods.
</p>
<p>
Take a look at this <a href="../examples3/">extensive example</a>, where WCH successfully works with:
</p>
<ul>
<li>drop-downs</li>
<li>Flash movies</li>
<li>Quicktime video</li>
</ul>
<p>
As a side note…did you notice the W3C Schools are <a href="http://www.w3schools.com/media/media_quicktime.asp">recommending</a> non-standard way of including Flash or other media objects? Shameful. :(
</p>
<h5>How to use it</h5>
<p>
You need to include the <code>WCH.js</code> in your page, and then simply call the methods. I have renamed the functions to be less confusing.</p>
<pre>
WCH.Apply(Layer, Container);
WCH.Discard(Layer, Container);
</pre>
<p>
So, when you are showing your layer, just call <code>Apply</code> method. When you are removing your layer, simply call <code>Discard</code> method.<br />
<br />
News is that both parameters can either be an <code>id</code> or a reference. WCH will internally fetch the reference if <code>id</code> is passed.
</p>
<p><span id="more-57"></span></p>
<h5>How it works</h5>
<p>
Here is the part for those who want to further expand it, if they need to.<br />
<br />
WCH object is created during page load, and a set of properties and methods is defined.
</p>
<pre>
var WCH = new function() {
	<span class="code-comment">//	internal properties</span>
	this._bIE50 = (document.all &amp;&amp;
			document.getElementById &amp;&amp;
			!window.opera &amp;&amp;
			navigator.userAgent.toLowerCase().indexOf("mac") == -1);
	this._bIE55 = false;
	this._bIE6 = false;
	this._oRule = null;
	this._bSetup = true;
	<span class="code-comment">//	public methods</span>
	this.Apply = function(vLayer, vContainer) {
		if (!this._bIE50) return;
	};
	this.Discard = function(vLayer, vContainer) {
		if (!this._bIE50) return;
	};
	<span class="code-comment">//	internal methods</span>
	this._Hider = function(vLayer, vContainer)
	this._GetObj = function(vObj)
}
</pre>
<p>
Internal objects are denoted with leading underscore. The entry guardian, <code>_bIE50</code> is set during page load. The long condition is there is to ensure that only IE5+ Windows will execute the code. Any browser that understand Javascript will pass-through all the code, but you see that all but IE5/Win is sent back. This way, you don’t need to do <code>if (WCH) WCH.Apply(...)</code> but simply call the method with <code>WCH.Apply(...)</code>. I prefer clean code. :)
</p>
<p>
The other detections (IE55 and IE6) are done on the first call to <code>Apply</code>. This must be done after the page load, and this way I don’t have to use <code>window.attachEvent</code>.
</p>
<pre>
if (this._bSetup) {
	this._bIE55 = this._bIE50 &amp;&amp; typeof(document.body.contentEditable) != "undefined";
	this._bIE6 = this._bIE55 &amp;&amp; typeof(document.compatMode) != "undefined";
	if (document.styleSheets.length == 0)
		document.createStyleSheet();
	this._bSetup = false;
}
</pre>
<p>
Basic functionality, for IE5.5+ is the same as before, the only difference being that sizing and positioning of <code>iframe</code> is done in the <code>_Hider</code> “constructor”, where it logically belongs.<br />
<br />
The fun part is with IE5.0.
</p>
<h5>Hide and show with dynamic style rules</h5>
<p>
As with WCH 2.5, the only thing that page coder must do is to attach <code>WCHhider</code> class to any element that must be hidden when layer pops up. Make sure that, in your own style sheets there is no such class.
</p>
<p>
When <code>Apply</code> is called for the first time, script will add simple rule that hides the element, and save the pointer to the rule as WCH internal property.
</p>
<pre>
if (this._oRule)
	this._oRule.style.visibility = "hidden";
else {
	var oSheet = document.styleSheets[0];
	oSheet.addRule(".WCHhider", "visibility:hidden");
	this._oRule = oSheet.rules(oSheet.rules.length-1);
}
</pre>
<p>
Rule is added to the first style sheet loaded<sup>1</sup>. If there are no style sheets, one is created during setup (see code above).<br />
<br />
On any subsequent call, simply change the rule to either <code>visibility:hidden</code> (for Apply) or <code>visibility:visible</code> (for Discard). That is all. Simple and sweet.
</p>
<p class="footnote">
1 : This could be problematic if you use style switcher, when you must add the rule to every style sheet.</p>
]]></content:encoded>
			<wfw:commentRss>http://aplus.rs/wchdev/wch3-works-in-ie50/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>WCH 2.5 — IE 5.0 support</title>
		<link>http://aplus.rs/wchdev/wch-25-ie-50-support/</link>
		<comments>http://aplus.rs/wchdev/wch-25-ie-50-support/#comments</comments>
		<pubDate>Thu, 18 Mar 2004 09:54:14 +0000</pubDate>
		<dc:creator>Aleksandar</dc:creator>
				<category><![CDATA[WCH]]></category>

		<guid isPermaLink="false">http://www.aplus.co.yu/?p=54</guid>
		<description><![CDATA[From this moment on, I will maintain two version of the WCH2 script. One will support IE 5.5+ (version 2.0x) and other will support IE 5.0+ (version 2.5x). In IE ...]]></description>
			<content:encoded><![CDATA[<p>
From this moment on, I will maintain two version of the WCH2 script. One will support IE 5.5+ (version 2.0x) and other will support IE 5.0+ (version 2.5x). In IE 5.0 we need to hide the windowed controls when absolute layers popup, and show them again then layers are removed.
</p>
<h5>Basic idea</h5>
<p>
My goal was to make the life of web page builder as simple as possible. Therefore, the only thing you need to do is to add the class name <code>WHChider</code> (case-sensitive) to the elements that needs to be hidden when layer pops up.
</p>
<pre>
&lt;select ... class="WCHhider"&gt;
&lt;select ... class="sample WCHhider"&gt;
</pre>
<p>
As you can see, even if you already have a class, just add this one too. IE 5.0 supports multiple class names.
</p>
<p>
Check-out <a href="../examples2/">this example</a>, which shows what WCH2 does.
</p>
<p><span id="more-54"></span></p>
<h5>How it works</h5>
<p>
I will just note the differences and added code from <a href="../112/">version 2.02</a>.
</p>
<p>
First change is in the <code>WCH_Hider</code> function, where IE5.0 code is added.
</p>
<pre>
<span class="code-comment">//	is this IE 5.5 or higher?</span>
bIsIE55 = (bBrowserOk &#038;&#038; typeof(document.body.contentEditable) != "undefined");

<span class="code-comment">//	for IE5.0, use special hiding based on class name</span>
if ( !bIsIE55 ) {
	var aToHide = document.WCHhider;
	if (typeof(aToHide) == "undefined") {
		aToHide = xGetElementsByClassName( "WCHhider" );
		document.WCHhider = aToHide;
	}
	return aToHide;
}
</pre>
<p>
The goal is to fetch the pointers to all elements that have our class name. The latest version of <a href="http://cross-browser.com/">X library</a> (at this moment that is 3.15.1) has the function that does just that, xGetElementsByClassName(). If you call it with class name only, it will return an array of all elements inside of <code>document</code> that have that class name.<br />
<br />
To avoid the slow DOM tree-walk, we save that array in the document, for later use.<br />
<br />
Instead of all elements, you can work with just drop-downs, when you need to use full calling form. Second parameter is the parent element (function will return an array of child nodes of that element) and the third parameter is the node name (function will return the child nodes with that node name).
</p>
<pre>
aToHide = xGetElementsByClassName( "WCHhider", document, "select" );
</pre>
<p>
That array is then returned to the calling function.
</p>
<h5>Hiding and showing</h5>
<p>
Since type of returned result is <code>object</code> in both cases (when array is returned and when iFrame reference is returned), we will distinguish between using <code>length</code> property. If <code>length</code> is <code>undefined</code>, the result is iFrame, and we proceed with code we know from version 2.0x. If length is defined, then we have an array, and all that needs to be done is to hide the elements of the array:
</p>
<pre>
for (var i=0;i&lt;oIframe.length;i++)
	oIframe[i].style.visibility = "hidden";
</pre>
<p>
In the opposite function, we do the same, only this we set the <code>visibility</code> property to <code>visible</code>.
</p>
<p>
That is all.<br />
<br />
Version 2.5 includes two function from X library – if you use that library in full, simply delete them from WCH script to save download bytes.</p>
]]></content:encoded>
			<wfw:commentRss>http://aplus.rs/wchdev/wch-25-ie-50-support/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>WCH 2</title>
		<link>http://aplus.rs/wchdev/wch-2/</link>
		<comments>http://aplus.rs/wchdev/wch-2/#comments</comments>
		<pubDate>Fri, 05 Mar 2004 21:53:59 +0000</pubDate>
		<dc:creator>Aleksandar</dc:creator>
				<category><![CDATA[WCH]]></category>

		<guid isPermaLink="false">http://www.aplus.co.yu/?p=46</guid>
		<description><![CDATA[After the last post, I knew that only IE/Win had any benefit from this script. This way I was able to streamline the script and completely remove the dependency on ...]]></description>
			<content:encoded><![CDATA[<p>
After the last post, I knew that only IE/Win had any benefit from this script. This way I was able to streamline the script and completely remove the dependency on other scripts. It’s not even needed to do anything on the page load. I also removed the support for IE 5.0 and concentrated on iFrame technique. And it’s a lot smaller: 4.65kB, heavily commented.
</p>
<p>
Script now has only three functions. <code>WCH_Hider()</code> does all the browser checks and creates the hiding iFrame. <code>WCH_HideWndCtrl()</code> is placing the hider below the layer that needs to go over windowed controls. <code>WCH_ShowWndCtrl</code> is removing the hider.
</p>
<p>
For those of you wondering what this is all about…read <a href="../102/">this entry</a> that will explain the problem at hand. Now, on to version 2. I will still explain every part of the script, as I think that this version should be used in the future – it’s much smaller, faster, independent…simply better.
</p>
<p><span id="more-46"></span></p>
<h5>How to use it</h5>
<p>
This script is useful if you have dynamic layers that pop-out after page load, like <a href="/adxmenu/">menu scripts</a>, fancy widgets and similar stuff. To prevent drop-downs to show through your layer, just call the function that will hide the portion of drop-down where layer is located.
</p>
<pre>
if ( typeof(WCH_HideWndCtrl) != "undefined" )
	WCH_HideWndCtrl(this.submenu, this);
</pre>
<p>
This type of calling allows you to freely work, regardless if WCH is actually loaded or not. When your layer is hidden, just call the opposite function in the same way:
</p>
<pre>
if ( typeof(WCH_ShowWndCtrl) != "undefined" )
	WCH_ShowWndCtrl(this.submenu, this);
</pre>
<h5>Creating Hider</h5>
<p>
<code>WCH_Hider</code> still takes the same two parameters: layer under which hider should be placed and the container for both of them. If the first parameter is not passed (i.e. nothing is passed), it simply exits. Then we check for browser compliance. Only IE5+/Win will pass this check:
</p>
<pre>
var bBrowserOk = (document.all &#038;&#038; document.getElementById);
if ( !bBrowserOk ) return null;
</pre>
<p>
And only IE5.5+ will pass this check:
</p>
<pre>
bBrowserOk = (bBrowserOk &#038;&#038;
typeof(document.body.contentEditable) != "undefined");
if ( !bBrowserOk ) return null;
</pre>
<p>
Object detection at its best (for the first time in my dev life, MSDN was very useful). No user-agent spoofing can trick this.<br />
<br />
After this line, I try to access the hiding iFrame element. If it’s there, jolly good, work done. If not, create it. First, we need a container, where hider iFrame will be inserted. That pointer is passed in the function call. If it’s not, assume it’s body.
</p>
<pre>
if ( typeof(vContainer) == "undefined" )
	oContainer = document.getElementsByTagName("BODY")[0];
else if ( typeof(vContainer) == "string" )
	oContainer = document.getElementById(vContainer);
else
	oContainer = vContainer;
</pre>
<p>
There is one nice IE/Win’s proprietary style rule that allows the execution of various visual filters. Here, <code>Alpha</code> filter is very useful, as it is rendering the frame invisible (this is not the same as CSS’ <code>visibility</code>). Unfortunately, my test showed that applying the filter in IE5.5, even with SP2 installed, crashes the browser. Hence another object detection (compatMode property exists only in IE6+):
</p>
<pre>
var sFilter = (typeof(document.compatMode) != "undefined")
? "filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0);" : "";
</pre>
<p>
Next, we need to get the value of <code>z-index</code> for our layer (remember, we need to place the hider one z-index step below the layer). First try with DOM, then with runtime style (value from stylesheet files). If we can’t get the value, or it’s less than two, do nothing since there is no room for the hider.
</p>
<pre>
var zIndex = oLayer.style.zIndex;
<strong>if ( zIndex == "" )</strong>
	zIndex = oLayer.currentStyle.zIndex;
zIndex = parseInt(zIndex);

if ( isNaN(zIndex) ) return null;
if (zIndex &lt; 2) return null;
</pre>
<p class="update">March 17: I have changed the highlighted line above from <code>if ( zIndex == "" &#038;&#038; document.compatMode == "CSS1Compat" )</code> to shown one. Second condition effectively excluded IE5.5 (as zIndex was always 0 then and it got out on the last line), causing the script not to have effect in it.
</p>
<p>
Finally, create the hider element and get its pointer (line breaks added for clarity).
</p>
<pre>
zIndex--;
oContainer.insertAdjacentHTML("afterBegin",
	'&lt;iframe src="about:blank" id="hider' + oLayer.id + '"' +
	' scroll="no" frameborder="0"' +
	' style="position:absolute;visibility:hidden;' +
	sFilter +
	'border:0;top:0;left;0;width:0;height:0;' +
	'background-color:#ccc;z-index:' + zIndex + ';"&gt;' +
	'&lt;/iframe&gt;'
);
oIframe = document.getElementById("hider" + oLayer.id);
</pre>
<p>
Initially, hider is hidden. It first need to be given proper size and position.
</p>
<h5>Hide / show</h5>
<p>
Both hiding and revealing functions call the previous one. Work is done is valid object pointer is returned. In the function that hides everything below the layer, <code>WCH_HideWndCtrl</code>, we first get the layer size and apply it to the hider and then do the same for position, before we change its visibility.
</p>
<pre>
oIframe.style.width = oLayer.offsetWidth + "px";
oIframe.style.height = oLayer.offsetHeight + "px";

oIframe.style.left = oLayer.offsetLeft + "px";
oIframe.style.top = oLayer.offsetTop + "px";

oIframe.style.visibility = "visible";
</pre>
<p>
In the opposite function, we simply hide the hider, thus revealing everything below it.
</p>
<h5>Wait? Something missing…</h5>
<p>
Yup, there is no IE 5.0 support. This fancy iFrame hiding is not possible there. In the 1st gen of this script, I collected the pointers to windowed controls and then hide them with <code>visibility:hidden</code>. I didn’t like that too much, as it added 50% more code for 10% more users.<br />
<br />
Should this be added? I’m still thinkin’ about it…</p>
]]></content:encoded>
			<wfw:commentRss>http://aplus.rs/wchdev/wch-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>SSL fix for IE</title>
		<link>http://aplus.rs/wchdev/ssl-fix-for-ie/</link>
		<comments>http://aplus.rs/wchdev/ssl-fix-for-ie/#comments</comments>
		<pubDate>Tue, 02 Mar 2004 12:09:51 +0000</pubDate>
		<dc:creator>Aleksandar</dc:creator>
				<category><![CDATA[WCH]]></category>

		<guid isPermaLink="false">http://www.aplus.co.yu/?p=44</guid>
		<description><![CDATA[I today encountered a problem with Internet Explorer (oh, well, I know). I used ADxMenu on the page that was under SSL. Page loads fine. Then, I hover the menu ...]]></description>
			<content:encoded><![CDATA[<p>
I today encountered a problem with Internet Explorer (oh, well, I know). I used <a href="/adxmenu/">ADxMenu</a> on the page that was under SSL. Page loads fine. Then, I hover the menu actuator, which brings up the famous dialog:
</p>
<blockquote><p>
This page contains both secure and non secure items.<br />
<br />
Do you want to display the non secure items?
</p></blockquote>
<p>
There was nothing wrong with the menu, but with WCH script. If you <a href="/wch/those-things-that-refuse-to-obey/">remember</a>, it creates iFrame element on the fly and places it below the menu.<br />
<br />
Well, if you don’t have the <code>src</code> specified for the iFrame, IE treats it as unsecure item, hence the dialog. Solution is simple, as usual (once you find out what is the problem):
</p>
<pre>
oHiderContainer.insertAdjacentHTML("afterBegin",
   '&lt;iframe <strong>src="/inc/e.html"</strong> id=...&gt;&lt;/iframe&gt;');
</pre>
<p>
Rest of the line stays the same. This e.html is a simple empty file already present in the project. Use anything you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://aplus.rs/wchdev/ssl-fix-for-ie/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Can you place layers over flash files or drop downs?</title>
		<link>http://aplus.rs/wchdev/can-you-place-layers-over-flash-files-or-drop-downs/</link>
		<comments>http://aplus.rs/wchdev/can-you-place-layers-over-flash-files-or-drop-downs/#comments</comments>
		<pubDate>Mon, 08 Dec 2003 10:11:19 +0000</pubDate>
		<dc:creator>Aleksandar</dc:creator>
				<category><![CDATA[WCH]]></category>

		<guid isPermaLink="false">http://www.aplus.co.yu/?p=24</guid>
		<description><![CDATA[I've run extensive testing on Windows and Mac browsers to see how they handle drop-downs and object tags (Flash files) in combination with absolutely positioned layers.]]></description>
			<content:encoded><![CDATA[<p>
It is a known fact that some browsers can’t draw layers (absolutely positioned) over Flash files or drop-down boxes.  To see why that happens, refer to my <a href="/wch/those-things-that-refuse-to-obey/">first WCH post</a>, which was my first tackle with this problem.
</p>
<p>
Now, after extensive testing in several Windows and Mac browsers, I have much better picture how all this works.
</p>
<p><span id="more-24"></span></p>
<p>
If you look at the <a href="../examples/">example page</a>, you’ll find two sets of tests. First, I wanted to see how browsers handle <code>object</code> (or <code>embed</code>) element which loads Flash file without <code>wmode="transparent"</code> parameter (read more about this in <a href="http://www.macromedia.com/support/flash/ts/documents/wmode.htm" title="How to make a Flash movie with a transparent background">Macromedia tech note</a>). I applied WCH script to second layer only.<br />
<br />
In the lower set, I added <code>wmode</code> parameter, and applied WCH again.
</p>
<h5>Windows browsers</h5>
<ul>
<li>IE 6: needs WCH to cover drop-downs and Flash. Transparent Flash is always covered, regardless of WCH.</li>
<li>IE 5.5: needs WCH to cover drop-downs and Flash. Transparent Flash is always covered, regardless of WCH.</li>
<li>IE 5.0: WCH uses show/hide workaround. Transparent Flash is always covered, regardless of WCH.</li>
<li>Firebird 0.7: always cover drop-down, only transparent Flash. Transparent Flash is always covered, regardless of WCH.</li>
<li>Opera 7.22: always cover drop-down, never covers Flash (WCH is properly applied but it has no effect – actually it hides the layer itself?!)</li>
</ul>
<p>
It’s an obvious conslusion that WCH can be used only with IE 5.0+ to have any real effect. Since IE/Win rules the end-user market, this script comes very handy.
</p>
<h5>Mac</h5>
<ul>
<li>OmniWeb 4.5: always covers drop-down, never covers Flash</li>
<li>IE 5.2 Mac: always covers drop-down, only transparent Flash</li>
<li>Opera 6.03 Mac: never covers either drop-down or Flash</li>
<li>Camino 0.7: always cover drop-down, only transparent Flash</li>
<li>Firebird 0.7: always cover drop-down, only transparent Flash</li>
<li>Safari 1.1: always covers drop-down, only transparent Flash (initially all covered, until flash animation starts which then removes the layer)</li>
</ul>
<p>
Conclusion: newer Mac browsers always cover drop-downs (all but Opera 6.03). Flash can be covered if <code>wmode=transparent</code> is used. WCH has no effect in any Mac browser.
</p>
<h5>Recommendation</h5>
<p>
WCH script has changed according to findings above. Since it’s usable only in IE/Win, I added the check for this, since its use cause problems in some browsers (Opera, Opera…).<br />
<br />
Script uses <code>insertAdjacentHTML</code>, an IE native function, to insert the hiding iFrame. Since script does not deal with any other browser, I have removed almost 3kB of code needed to emulate that method in other browsers. If you need that code (as it is very handy), download it by <a href="/scripts/InsertElement.js">right-clicking here</a>.
</p>
<p>
I recommend you always use <code>wmode="transparent"</code> when loading Flash files, and use WCH on for IE/win.</p>
]]></content:encoded>
			<wfw:commentRss>http://aplus.rs/wchdev/can-you-place-layers-over-flash-files-or-drop-downs/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Those things that refuse to obey</title>
		<link>http://aplus.rs/wchdev/those-things-that-refuse-to-obey/</link>
		<comments>http://aplus.rs/wchdev/those-things-that-refuse-to-obey/#comments</comments>
		<pubDate>Wed, 15 Oct 2003 23:28:59 +0000</pubDate>
		<dc:creator>Aleksandar</dc:creator>
				<category><![CDATA[WCH]]></category>

		<guid isPermaLink="false">http://www.aplus.co.yu/?p=9</guid>
		<description><![CDATA[Library of functions which will hide any windowed control on the page and thus eliminate show-through-layers problem.]]></description>
			<content:encoded><![CDATA[<p>
While developing <a href="/adxmenu/">AD xMenu</a>, this script was incorporated to allow menu to pass over select boxes and similar windowed controls.<br />
It worked so good, and was so easy to implement it for any layer, that I moved it to separate script and added few bits to ease-off integration with other scripts.
</p>
<h5>What’s it for?</h5>
<p>Take a look at this example. Maroon layer is absolutely positioned and it goes over select box.</p>
<div class="postexample">
<div style="position:relative;">
<div style="position:absolute;left:50px;width:100px;height:30px;color:#fff;background-color:#800;">over drawn</div>
<form action="#">
<select>
<option>irelevant content&#8230;</option>
<option>irelevant content&#8230;</option>
</select></form>
</p></div>
</div>
<p>
Did I said over?<br />
In the old days, when there was nothing dynamic about HTML, browser makers used OS controls to draw HTML form elements. That means that they were at the “lower-level” compared to HTML browser engine and was thus untouchable for web authors. This was most obvious in revolutionary IE4. Microsoft changed this in IE5 (all form elements but drop-downs), further enhanced it in 5.5 (iframes were also moved to HTML engine); other newer browsers followed similar path.
</p>
<p>
If you are using Gecko-based or Opera 7 browser, then you don’t see a need for this script (as everything is displayed correctly for you). Same goes for Safari, as I hear. But you are a very small minority. Regular Windows users (those that we make websites for), use IE. And IE still uses OS control for one form element: select list (aka drop-down box).<br />
So in IE, drop-down punch through the layer.
</p>
<p>This script uses one fine trick to overcome this problem. (<em>Danger ahead</em>: in the following text, I will identify term browser with IE).</p>
<p><span id="more-9"></span></p>
<h5>The old way…</h5>
<p>
This was usually the problem with layers that appeared when hovering some spot (since you can’t really control what is below the area where layer appears).<br />
It became a nuisance and only available technique was to hide form elements when layer is shown. But if you have large number of form elements, then that takes a long time, sometimes up to 10s, which frustates the user (since it totally blocks IE).
</p>
<p>Since IE 5, problem was greatly minimized – I have yet to see a web page which have this amount of drop-down boxes (that will be a usability nightmare by itself). So, all web developer needed to do is something like this:</p>
<pre>
var aDD = new Array();
...
aDD[aDD.length] = "document.forms['form name'] _
   .elements['drop-down name']";
</pre>
<p>(” _” was used to denote display break. In real code, connect these two lines.)</p>
<p>This will collect pointers to all select elements on the page. When layer is shown, do <code>eval()</code> for all this with <code>style.visibility = "hidden"</code>.</p>
<p>This is how WCH is still doing, when it detects IE5 (functions <em>WCH_HideWndCtrl4Oldies()</em> and <em>WCH_ShowWndCtrl4Oldies()</em> in the script). In the <em>WCH_Initialize()</em> function, change this line to point to your array (aDD from above).</p>
<pre>
if ( !WCH_bSupportHider &#038;&#038; xDef(SG_aDDs) ) {
	WCH_aDropDown = SG_aDDs;
}
</pre>
<h5>The new way</h5>
<p>In IE5.5, Microsoft has changed its code so that iFrame was drawn from HTML engine. And since it was a frame, it was drawn over any windowed control on the page. Unknown programer came up with idea to use this feature to resolve the problem at-hand, and contacted Joe King who wrote <a href="http://dotnetjunkies.com/weblog/jking/posts/488.aspx">this explanation</a>.</p>
<p>So, we need to dynamically insert the iFrame just below the layer in the z-index order and problem solved. IE’s <em>insertAdjacentHTML</em> function is used for that, emulated for other browsers using <a href="http://www.faqts.com/knowledge_base/view.phtml/aid/5756">Thor Larholm’s code</a>.</p>
<p>For this script to work, <em>WCH_Initialize</em> should be executed on <code>window.onload</code>. Then add this call to your show-layer function:</p>
<pre>
WCH_HideWndCtrl(oLayer, oNewHiderContainer);
</pre>
<p>and this code for hide-layer function:</p>
<pre>
WCH_ShowWndCtrl(oLayer, oNewHiderContainer);
</pre>
<p>
oLayer is the layer object you are displaying. By default, iFrame is inserted as a child of the body element. This is fine, if you don’t use <code>position:relative</code> on the page when <a href="/css/ie-phone-book/" title="how z-index really works">“phone-book”</a> feature kicks-in. This means that if you have a layer with z-index of 100 inside of relatively positioned box, hider iFrame with z-index of 99 (WCH script will give him this, but it will be the same if it has value of 1) will be <strong>above</strong> the layer.<br />
So, in such case, pass the object representing the position container as the second parameter.
</p>
<p>And that is all. Have fun and report back any problems you encounter.</p>
]]></content:encoded>
			<wfw:commentRss>http://aplus.rs/wchdev/those-things-that-refuse-to-obey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)

Served from: aplus.rs @ 2012-02-07 18:39:48 -->
