tags:

views:

68

answers:

1

The second link does not work like the first one. How come?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Dynamic CSS Properties</title>   
    <script language="JavaScript">
    function change(){
    //document.getElementById("box1").style.visibility = "visible";

    var spanArray = document.getElementsByTagName('span');
   var number_spans = spanArray.length ;
   for( var i = 0; i < number_spans ; i++ ){
   var target = spanArray[ i ] ;
      // do something with target like set visibility
      target.style.visibility = "visible";
   }
   }
   function change2(){
      var spanArray=document.getElementsByTagName('span');var number_spans=spanArray.length;for(var i=0;i<number_spans;i++){var target=spanArray[i];target.style.visibility="visible";}
   }
    </script>
</head>

<body>
<a href="javascript:change2();">Change</a>
<br />
<a href="javascript:var spanArray=document.getElementsByTagName('span');va r number_spans=spanArray.length;for(var i=0;i<number_spans;i++){var target=spanArray[i];target.style.visibility='visible';};
">Show Spans</a> 
<br />
<div style="position: relative; overflow: hidden;"><center>
<br><br>
<font size="5" color="blue">

1. just press the <img src="http://up203.siz.co.il/up1/jw2k4az1imny.jpg"&gt; button on the top to see the picture i promise you its so funny!!!!:
<br><br><br>

<span style="background: none repeat scroll 0% 0% white;"><span style="visibility: hidden;">

<a onmousedown="UntrustedLink.bootstrap($(this), &quot;77a0d&quot;, event)" rel="nofollow" target="_blank" onclick="(new Image()).src = '/ajax/ct.php?app_id=4949752878&amp;action_type=3&amp;post_form_id=3917211492ade40ee468fbe283b54b3b&amp;position=16&amp;' + Math.random();return true;" href="http://thebigbrotherisrael.blogspot.com/2010/04/all-family-guy-characters-in-real-life.html"&gt;Press here to see the picture!!!</a>

</span><span style="visibility: visible;"></span></span></font></center></div>

</body>
</html>
+1  A: 

There's a typo in your code.

va r number_spans=spanArray.length

in the link for show spans

Also, why would you want to do this way and not just use the onclick and wrap it in a function?

Chris Thompson
I am not familiar with Javascript so I'm not sure what exactly you are talking about the onClickbut if you mean something like<a href="#" onClick="">Click</a>I dont want to do that because the objective of this script is to bypass the needing to become a fan/like on Facebook to see certain content. If I had it as a link I do not think it will be as portable.and thank you, I have corrected that typo. now the link is working and it is showing the hidden content, but replacing the content with 'visible' immediately after. (minus ' ')
imHavoc
I don't fully understand what you are trying to do. I don't see a reference to Facebook in your code, so I'm not sure how that comes into play. The `onclick` property is the "correct" way to execute javascript when somebody clicks something.
Chris Thompson
after the two links "Change" "Show Span" there is a <div> that <div> I took from a Facebook page to use as a mock-up. And because I want to be able to bookmark the javascript so the user can access it while on the facebook page, I do not believe an onclick is possible?
imHavoc