Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Synter
Sep 22, 2004

College Slice
I've been working on a Firefox extension, and I'm having trouble with a particular javascript function.

code:
function GetStatus(timeout) {
  var sreq = new XMLHttpRequest();
  sreq.onreadystatechange = function (aEvt) {
    if (sreq.readyState == 4) {
      if(sreq.status == 200) {
	    var img = document.write("http://url.com/Smileys/sa/" + sreq.responseText);
        document.getElementById("WOPR-ImgLeft").value = img;
		document.getElementById("WOPR-ImgRight").src = "http://url.com/Smileys/sa/goonpatriot.png";
      }
    }
  };
  sreq.open('GET', URL()+'/toolbar_status.php', true);
  sreq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  sreq.send(null);
  if (timeout) {
    setTimeout ("GetStatus()", 1000*60*30);
  }
}
The function is supposed to recursively call itself every 30 minutes (it does), retrive the image name from toolbar_status.php (it does) and point two images that appear in the toolbar to it.

I have tried multiple combinations of document.getElementById(image id).value and .src with combinations of the above image options (document.write("http://url.com/Smileys/sa/" + sreq.responseText) and a direct url like "http://url.com/Smileys/sa/goonpatriot.png") and neither seem to work.

The part of overlay.xul in particular is correct as far as I can tell, but posting it just in case:
code:
<toolbaritem flex="0" height="20">
	<image id="WOPR-ImgLeft" />
</toolbaritem>
<toolbaritem flex="0" align="center">
	<label id="WOPR-GetMessage" />
</toolbaritem>
<toolbaritem flex="0" height="20">
	<image id="WOPR-ImgRight" />
</toolbaritem>
Edit:

Never mind, fixed.
Going to write "I shouldn't be using document.write to concatenate strings" 100 times on the blackboard

Synter fucked around with this message at 12:49 on Jun 27, 2009

Adbot
ADBOT LOVES YOU

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply