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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link to External URL with innerHTML 1

Status
Not open for further replies.

larrydavid

Programmer
Jul 22, 2010
174
0
0
US
Hello,

I am trying to link to an external URL and have confirmed that the link is good (I can paste it in the address bar of my browser and it goes fine). But I need to surround the link in hyperlink tags so the user can click on it to go to the URL from my web page. Here is the code:

Code:
td.innerHTML = "<a href=\"[URL unfurl="true"]http://TESTSERVER123/reportserver?/Data_Analysis/Billed_Charges_Per_Customer&rs:Command=Render&CustomerId="[/URL] + customer.TIN + "\" target=\"_blank\">" + "</a>";

I have been researching the syntax on this and from what I can gather I am probably not escaping the slashes properly in my link, but I am stumped at this point. Any help would be greatly appreciated.

Thanks,
Larry
 
try escaping the ampersands
...Customer&rs:Command=Render&CustomerId...
should be
...Customer&amp;rs:Command=Render&amp;CustomerId...
 
Your escaping is fine. But the fact there's nothing to click on in your link makes it hard to see a usable link.

Code:
td.innerHTML = "<a href=\"[URL unfurl="true"]http://TESTSERVER123/reportserver?/Data_Analysis/Billed_Charges_Per_Customer&rs:Command=Render&CustomerId="[/URL] + customer.TIN + "\" target=\"_blank\">"[red]>>[/red] + [red]<<[/red]"</a>";

You are closing your link immediately after opening it. So your link has no real surface to click on. Add some text there to give it a clickable area.

Code:
td.innerHTML = "<a href=\"[URL unfurl="true"]http://TESTSERVER123/reportserver?/Data_Analysis/Billed_Charges_Per_Customer&rs:Command=Render&CustomerId="[/URL] + customer.TIN + "\" target=\"_blank\">" + [red]"Some Text To Click" +[/red] "</a>"

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thank you all for your advice. You are correct vacunita, I simply needed to add clickable text and it works now. Thank you so much!

Larry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top