Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a href problem

Status
Not open for further replies.

tmcneil

Technical User
Nov 17, 2000
294
US
I have this piece of code that's problematic and I am not sure what is wrong with it.

Code:
<% if (theOnlink.length() != 0) { %>
  <a href="<%= theOnlink %>" + ' target="_blank"' 
        onMouseOut="MM_swapImgRestore()"
        onMouseOver="MM_swapImage('linkToContent<%=loopNumber%>','','images/linktocontent_press.gif',1)"><img name="linkToContent<%=loopNumber%>" src="images/linktocontent_off" width="90" height="28" border="0" alt="<%= resBundle.getString("linkcontent_button") %>"></a>
<% } %>

The <%= theOnlink %> variable contains a url. Any ideas on what maybe wrong?

Thanks,
Todd
 
The error you are getting would be helpful...

But from a quick glance, it looks like theOnLink is an array since you are calling the length() method on it.

So without knowing how theOnLink is created, it is hard to help out further. Perhaps try:

Code:
<a href="<%= theOnLink.get(0) %>"...
?
 
You may post most code if you want us to help.
<% if (theOnlink!=null && theOnlink.length() != 0) { %>

// theOnLink.get(0) is wrong because theOnlink.length() is used
to check the length of a String.
 
That is not true. The length method can be used on arrays as well which makes my solution correct. But we don't know what the variable is.
 
I am sorry... you are right Prosper. I was thinking JavaScript not Java.
 
MikeyJudd and prosper,

The <%= theOnlink %> is a variable that stores a shared drive that contains pdf documents. When clicking on a button, a new browser opens with the pdf document. The value looks like this:

\\<machine name>\pdr\Metadata\Maps\BLS\LABOR\Labor_Force_Participation.pdf

I always thought the code that I posted was ok and it turns out that when I was trying to clear the browser cache, the old code was still getting hung up in the memory. I actually had to reboot the machine. I added one more "if" block around it to check for "static map images", so the "View Content" button shows up only when necessary. Everything seems to be working OK now.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top