Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem with JS and Firefox - Image Replacement
    text
    copied!<p>I have a simple JS function changing the background image of my website for each "page" - there are actually no separate pages, just JS changing the content area and background. Here is the code I have:</p> <pre><code> var selector = 'home'; function changeBG() { if( selector == 'portfolio' ) { document.bg_img.src = 'imgs/sandwiches/BLT_smlbw.jpg'; } else if( selector == 'contact' ) { document.bg_img.src = 'imgs/sandwiches/eggSammerSml.jpg'; } else { document.bg_img.src = 'imgs/plums4.jpg'; } } </code></pre> <p>and the HTML</p> <p><pre><code></p> <pre><code>&lt;!-- bg --&gt; &lt;img class="bg" id="bg_img" src="" alt="background_image" name="background_image" /&gt; &lt;!-- /bg --&gt; &lt;!-- content --&gt; &lt;div id="wrapper"&gt; &lt;!-- left nav --&gt; &lt;div id="left" class="content"&gt; &lt;img src="imgs/sandwich_logo.png" width="384" height="73" alt="sandwich_enthusiast" name="sandwich_enthusiast" /&gt; &lt;ul class="nav"&gt; &lt;li&gt;&lt;a href="#about" id="about"&gt;about&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" id="portfolio" onclick="selector = 'portfolio'; changeBG();"&gt;portfolio&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#contact" id="contact" onclick="selector = 'contact'; changeBG();"&gt;contact&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://glosee.ca/blog" id="blog"&gt;the sammers&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p> </pre></code></p> <p>In Chrome, Safari, and IE8 the image loads perfectly fine, but in FF the image loads as a background image in the wrapper div on the first click, then into the overall background on a second click.</p> <p>Any ideas of how this can be fixed?</p> <p>Thanks</p>
 

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