Home arrow JavaScript arrow Page 3 - Working with IFRAME in JavaScript
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Working with IFRAME in JavaScript - How to open a dynamic page in IFRAME using JavaScript: discussion
(Page 3 of 6 )

Within the code in the previous section, I mainly created a simple text box and a button.  The textbox is named “txtWebSite” and the button is named “Button1.”  The button is defined with an “onclick” event which calls a JavaScript function, “Button1_onclick”, which is defined as follows:

function Button1_onclick() {
var v = document.all("txtWebSite").value;
ShowWebSite(v);
}

The above function defines a variable “v” which is assigned with a value available (or typed) in the textbox “txtWebSite.”  The same variable is passed as a parameter to another JavaScript function, “ShowWebSite.” 

The function “ShowWebSite” is defined as follows:

function ShowWebSite(val)
{
      document.all.myFrame.src=val;
      document.all.myFrame.style.visibility="visible";
}

The above function simply assigns the website name (which I typed in the text box) as the source of IFRAME.  This makes IFRAME search for that website and display it on the little block I specified through its style (or CSS).  The most important aspect of the above code is that I made IFRAME invisible by default.  It is shown only when the above function gets executed.  You must observe “visibility:hidden” in the following tag available in the previous code.

            <iframe  id="myFrame"  frameborder="0"  vspace="0"  hspace="0"  marginwidth="0"  marginheight="0"
                  width="100"  scrolling="yes"  height="100"  style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; Z-INDEX: 999; LEFT: 20px; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP: 100px; visibility:hidden;">
            </iframe>


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials