4 Replies Latest reply on Nov 6, 2012 4:10 PM by Aegis Kleais

    Problem with SRC and HREF empty tags

    Bandeira1820

      I was trying to run a validation software within our company's website that was developed using coldfusion.

      The website renders perfectly but it fails verification. This is the following error i get.

       

      This link is broken. The SRC or HREF is an empty string

      HREF=”” or SRC=”” can cause unexpected effects such as traffic spikes or cookie corruption.

       

      The code affected is:

       

      <a href="" onClick="window.open('#to_root#debug_mode.cfm?height=400,width=500,scrollbars=yes');return false;" target="_top" class="globalNavButton">Debug</a>

       

      I have tried to add a # sign to the href target, but that brought an error to the website and the page would not render.

      Would anyone be able to assist on how to bypass this issue?

       

      Thank you

       

        • 1. Re: Problem with SRC and HREF empty tags
          Carl Von Stetten Adobe Community Professional & MVP

          If the HREF tag is somewhere inside a <CFOUTPUT> tag, then you need to escape the pound sign by adding a second pound sign next to it (i.e. href="##" instead of href="#").

           

          -Carl V.

          • 2. Re: Problem with SRC and HREF empty tags
            Bandeira1820 Level 1

            Carl,

             

            I will try to make the suggested changes. If you don't mind the question, I am trying to learn as I go as well.

            In this case, it was inside the CFOUTPUT tag, which works for your solution, but what if it wasn't? Would the correct thing to do would be to add just one #? I am still trying to understand the logic and functionality of adding the # on the links.

             

            Sorry for the stupid questinos.

            • 3. Re: Problem with SRC and HREF empty tags
              Carl Von Stetten Adobe Community Professional & MVP

              @Bandeira1820,

               

              That is correct.  Inside <CFOUTPUT> tags (and other tags that process and render ColdFusion variables), the pound sign has special meaning.  It is a token that marks the start and end of a ColdFusion variable.  So inside <CFOUTPUT>, ColdFusion will stop at the tokens, extract the name of the variable that is between the tokens, look up the value of that variable, and then insert the value in place of the tokenized variable name.  When it is finished, all you see is the HTML content returned to your browser.

               

              Outside of <CFOUTPUT>, the pound sign reverts to whatever meaning it has within the HTML language.  If you are inside of <CFOUTPUT> and wish to actually pass a literal pound sign (as you do in this particular case), you have to escape it by adding a second pound sign right next to it.  Thus, when ColdFusion processes this bit of code, it sees the two pound signs together and knows that there is not a variable name to be found here, so it replaces the double pound sign with a single pound sign and moves on.

               

              -Carl V.

              • 4. Re: Problem with SRC and HREF empty tags
                Aegis Kleais Level 3

                Not to sound odd and all, but even if you wrap this in <cfoutput>, all you'll get is:

                 

                <a href="" onClick="window.open( '/whatever/this/var/equals/debug_mode.cfm?height=400,width=500,scrollbars=yes'); return false;" target="_top" class="globalNavButton">Debug</a>

                 

                Your href will stil be empty.

                 

                If you are concerned with validation (is this W3C validation?) know that an anchor tag doesn't need to have an href value if there isn't any value in it.  You may also find it beneficial if you segregate your HTML from JS funtionality (assign the event handler 'onclick' via JS).