0

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"> 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">Press here to see the picture!!!</a>

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

</body>
</html>
1
  • 2
    For one, the second link has va r instead of var, but more importantly, you should be binding onclick handlers rather than relying on the functionality of javascript:. Commented Apr 28, 2010 at 20:53

1 Answer 1

1

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?

Sign up to request clarification or add additional context in comments.

3 Comments

I am not familiar with Javascript so I'm not sure what exactly you are talking about the onClick but 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 ' ')
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.
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.