The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Help with javascript

Mace1370Mace1370 Registered User regular
edited January 2008 in Help / Advice Forum
Hey guys. My blog was working perfectly for months and then suddenly it stopped working.

http://mtgdrafts.blogspot.com

The problem is that when you click the "Pick" links in the blog posts nothing happens. Before, when it was working properly, the pick would appear.

Using the error console I found that "reveal_layer" is not being defined. Looking at the source code, it appears that the javascript is being condensed into a single line... for some reason. Here is what the code is:
<script type='text/javascript' language='JavaScript'>
<!--
function reveal_layer (object) {
  if (document.getElementById) {
    document.getElementById(object).style.display = 'inline';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].display = 'inline';
  }
  else if (document.all) {
    document.all[object].style.display = 'inline';
  }
}
function hide_layer (object) {
  if (document.getElementById) {
    document.getElementById(object).style.display = 'none';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].display = 'none';
  }
  else if (document.all) {
    document.all[object].style.display = 'none';
  }
}
-->
</script>

This is what I see when I view the page source:
<script language='JavaScript' type='text/javascript'>
<!-- function reveal_layer (object) { if (document.getElementById) { document.getElementById(object).style.display = 'inline'; } else if (document.layers && document.layers[object]) { document.layers[object].display = 'inline'; } else if (document.all) { document.all[object].style.display = 'inline'; } } function hide_layer (object) { if (document.getElementById) { document.getElementById(object).style.display = 'none'; } else if (document.layers && document.layers[object]) { document.layers[object].display = 'none'; } else if (document.all) { document.all[object].style.display = 'none'; } } -->
</script>

Now, what troubles me is the ending of the code. Normally I would put //--> instead of the --> that is there. However, blogger is being retarded and gives me an error whenever I try to do that.

Finally, when I copy and paste the code into blogger and save the template and then review the template code it looks like blogger is editing my code to this:
<script language='JavaScript' src='http://www.wizards.com/global/basic.js' type='text/javascript'/>
<script language='JavaScript' type='text/javascript'>
<!--
function reveal_layer (object) {
  if (document.getElementById) {
    document.getElementById(object).style.display = 'inline';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].display = 'inline';
  }
  else if (document.all) {
    document.all[object].style.display = 'inline';
  }
}
function hide_layer (object) {
  if (document.getElementById) {
    document.getElementById(object).style.display = 'none';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].display = 'none';
  }
  else if (document.all) {
    document.all[object].style.display = 'none';
  }
}
-->
</script>

I'm totally lost. What is going on here?

Mace1370 on

Posts

  • JHunzJHunz Registered User regular
    edited January 2008
    It looks like it's working just fine to me...
    Did you fix it already?

    JHunz on
    bunny.gif Gamertag: JHunz. R.I.P. Mygamercard.net bunny.gif
  • DaenrisDaenris Registered User regular
    edited January 2008
    Yeah, I can confirm also that this is working for me, so either you fixed it or it's possibly an issue with your browser for some reason.

    Daenris on
  • SzechuanosaurusSzechuanosaurus Registered User, ClubPA regular
    edited January 2008
    Yeah, works for me in Firefox 2.0.0.11 in OSX.

    If the JS is being condensed in certain browsers, it might be a better idea to create an external Javascript file and just have the page source it, rather than putting it all in the actual HTML page. Could be some sort of add blocker or something messing up the script on the page.

    Having it external is better practice anyway.

    Szechuanosaurus on
Sign In or Register to comment.