• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Problem with SRC and HREF empty tags

New Here ,
Nov 06, 2012 Nov 06, 2012

Copy link to clipboard

Copied

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

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 06, 2012 Nov 06, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 06, 2012 Nov 06, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Nov 06, 2012 Nov 06, 2012

Copy link to clipboard

Copied

@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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 06, 2012 Nov 06, 2012

Copy link to clipboard

Copied

LATEST

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation