Note that there are some explanatory texts on larger screens.

plurals
  1. POBeginner JavaScript/HTML Frame Communication
    primarykey
    data
    text
    <p>One of my assignments for my Web Design class is to create a page in which two frames communicate using JavaScript. There are four links on the lower frame (lower2.html) and when clicked, they're supposed to change the image in the upper frame (upper1.html) to the respective image but don't. Here's what I have:</p> <p><strong>File name: js-seventeen.html. This is the one I execute.</strong></p> <pre><code>&lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;HTML and JavaScript&lt;/TITLE&gt; &lt;/HEAD&gt; &lt;FRAMESET ROWS="140,*"&gt; &lt;FRAME NAME="upperFrame" SRC="upper1.html"&gt; &lt;FRAME NAME="lowerFrame" SRC="lower2.html"&gt; &lt;/FRAMESET&gt; &lt;/HTML&gt; </code></pre> <p><strong>File name: upper1.html. This is the upper frame that displays the images.</strong></p> <pre><code>&lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;HTML and JavaScript&lt;/TITLE&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;CENTER&gt; &lt;IMG NAME="upperImage" SRC="lions.gif"&gt; &lt;/CENTER&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p><strong>File name: lower2.html. This is the lower frame that contains the links that should change the images, but don't. No matter what I click, it stays on the default lions.gif.</strong></p> <pre><code>&lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;HTML and JavaScript&lt;/TITLE&gt; &lt;SCRIPT&gt; function setImage(number) { if (number==1) { parent.upperFrame.document.upperImage.src="lions.gif"; } if (number==2) { parent.upperFrame.document.upperImage.src="tigers.gif"; } if (number==3) { parent.upperFrame.document.upperImage.src="bears.gif"; } if (number==4) { parent.upperFrame.document.upperImage.src="ohmy.gif"; } return; } &lt;/SCRIPT&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;CENTER&gt; &lt;H2&gt;IMAGE LIST&lt;/H2&gt; &lt;TABLE&gt; &lt;TR&gt;&lt;TD&gt;&lt;A HREF="javascript:setImage(1)"&gt;1: LIONS.GIF&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt;&lt;TD&gt;&lt;A HREF="javascript:setImage(2)"&gt;2: TIGERS.GIF&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt;&lt;TD&gt;&lt;A HREF="javascript:setImage(3)"&gt;3: BEARS.GIF&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;TR&gt;&lt;TD&gt;&lt;A HREF="javascript:setImage(4)"&gt;4: OHMY.GIF&lt;/A&gt;&lt;/TD&gt;&lt;/TR&gt; &lt;/TABLE&gt; &lt;/CENTER&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p>I've looked through the book and as far as I can tell, I've done everything properly. Thanks in advance for your help.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload