Thursday, August 03, 2006

Insert invisible frame at will

Ever thought of inseting a "hidden" frame in your page, where you can do magical things? Well we all do. Invisible frame is the magic wand for java developers. Well, now you can keep your source(html, jsp, jsf, etc) clean and insert this frame with a function call.

Code below will not only insert a invisible frame, but it will also return you its handle. If you wish you can pass a frame id of your choice, or be careless and the code will generate one.
<br /> /*<br /> *Add a invisible frame in your document and get a handle to it.<br /> *It is not necessary to specify the frame id.<br /> */<br /> var frameCount = 0;<br /> function getInvisibleFrameHandle(frameId)<br /> {<br /> var frameName,html;<br /><br /> if (!frameId)<br /> frameName="_invisibleFrame__" + (frameCount++);<br /> else<br /> frameName = frameId;<br /> if (document.getElementById(frameName))<br /> return document.frames[frameName];<br /> else<br /> appendDocument("<iframe id=" + frameName + " style="visibility: visible; height: 0pt; width: 100%;">");&amp;amp;lt;br&amp;amp;gt; return document.frames[frameName];&amp;amp;lt;br&amp;amp;gt; } &amp;amp;lt;/xmp&amp;amp;gt;</iframe><br /><br />

0 Comments:

Post a Comment

<< Home