faqts : Computers : Programming : Languages : JavaScript : Frames

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

96 of 121 people (79%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I load a new URL into an IFRAME?
How can I load a new URL into an IFRAME?

May 18th, 2002 21:05
Daniel LaLiberte, Martin Honnen,


If you NAME your IFRAME e.g.
  <IFRAME NAME="anIframe" ...>
you can script
  window.frames.anIframe.location.href = 'whatever.html'
Example:
<HTML>
<HEAD>
<SCRIPT>
</script>
</head>
<BODY>
<A HREF="javascript: void 0"
   ONMOUSEOVER="window.frames.anIframe.location.href =
                  'http://JavaScript.FAQTs.com'"
>
JavaScript.FAQTs.com
</a>
<BR>
<IFRAME NAME="anIframe" SRC="http://www.FAQTs.com"
        WIDTH="400"></iframe>
</body>
</html>
You can also target a link, or post a form with a target that
is the name of the iframe.  This requires the user to take the
action that loads the iframe, whereas an assignment to the location.href
of the iframe can be done in any JavaScript code.
<BODY>
  <A HREF="http://JavaScript.FAQTs.com" TARGET="anIframe">
    JavaScript.FAWTs.com</A>
  <IFRAME NAME="anIframe" src=""
          WIDTH="400"></IFRAME>
</BODY>