'lo
This one is confusing me, causing 2 separate errors:
Consider this XHTML and javascript:
<!-- ########################## -->
<!-- SNIP -->
<head>
<script type="text/javascript"
src="http://login.gamespyid.com/ads/jscheck.aspx"></script>
<script type="text/javascript"
src="http://wrapper.gamespyid.com/a?pagetype=ccontent&size=468x60"></script>
<script type="text/javascript" src="GSScripts.js"></script>
</head>
<html>
<!-- SNIP -->
<ul id="ex_Subscribe">
<li><a href="Foo">Buy Games</a></li>
</ul>
<!-- SNIP -->
</html>
<!-- ########################## -->
The 1st Gamespy javascript *requires* a HTTP Referer (sic) field to be
present, fake any if you wish.
GSScripts.js contains this:
/////////////////////////
var legalsite = "NewPlanetSite";
var advertise = "/site/contact.shtml#ads";
var legal = "/site/legal.shtml";
var strAdsEnabled = "";
var strUpgradeLink = "";
window.onload = function() {
if ( adsAreDisabled ) {
strAdsEnabled = '<li><a
href="https://login.gamespyid.com/ads/ads.aspx?off=1">Enable Ads</a></li>';
} else {
strAdsEnabled = '<li><a
href="https://login.gamespyid.com/ads/ads.aspx">Disable Ads</a></li>';
}
if ( isLoggedIn ) {
strUpgradeLink = '<li><a
href="https://login.gamespy.com/Subscribe/upgrade.aspx">Upgrade
Now!</a></li>';
} else {
strUpgradeLink = '<li><a
href="http://net.gamespyid.com/linktrack/redirect.aspx?i=9565&t=http%3a%2f%2fsubscribe.igng amespy.com%2ffcup%2fhitpoints.html">Subscribe
Now!</a></li>';
}
var ulEx = document.getElementById("ex_Subscribe");
ulEx.InnerHtml = ulEx.InnerHtml + strAdsEnabled + strUpgradeLink;
}
/////////////////////////
And guess what?
It doesn't work! XD
The 2 problems are:
a) The "adsAreDisabled" variable declared and assigned in jscheck.aspx are
not carried over to GSScripts.js, so it throws an NRE error for the "if
(adsAreDisabled) {" line. Is there any workaround for this? (To see problem
#2 just comment out all the "if" and brace lines)
b) Setting the .InnerHtml property doesn't do anything; I did an "alert (
strAdsEnabled );" and that worked. But when I did "alert (
ulEx.InnerHtml );" I got "undefined". However, "alert ( ulEx );" works fine.
Any ideas?
Thanks