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

NS7 and IE condition in href tag 2

Status
Not open for further replies.

evergreean43

Technical User
Joined
May 25, 2006
Messages
165
Location
US
Is there a way to put conditions in an href instead of inside below script tags:
Code:
<script>
if(navigator.appname == "Netscape")
{
	document.write("<a href='site.cfm' title='netscape words here'>Link</a>");
}
else
{
	document.write("<a href='site.cfm' title='IE words here'>Link</a>");
}
</script>

My attempt is really far off but not sure how to do it?
Code:
<a href='site.cfm' title='if(navigator.appname == "Netscape")'netscape words here';else 'IE here';>Link</a>
 
Something like

Code:
<script>
    document.write("<a href='site.cfm' title=+" (navigator.appname == "Netscape")?'netscape words here':'IE words here'"+>Link</a>");
</script>

Cheers,
Dian
 
Thanks,

I get error message:
Expected ')'

Please advise.
 
If you can do this server-side, you are far better off doing so. If not, then this should fix your quote issue:

Code:
<script type="text/javascript">
    document.write('<a href="site.cfm" title="' + (navigator.appname == 'Netscape') ? 'Netscape words here' : 'IE words here' + '">Link</a>');
</script>

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks,

It keeps saying "Netscape words here" in both IE and Netscape.

Code:
<script type="text/javascript">
document.write('<a href="site.cfm" title="' +(navigator.appName == 'Netscape') ? 'Netscape words here' : 'IE words here' + '">Link</a>');
</script>

Please advise.
 
[tt]
<script type="text/javascript">
document.write('<a href="site.cfm" title="' +[COLOR=red yellow]([/color](navigator.appName == 'Netscape') ? 'Netscape words here' : 'IE words here'[COLOR=red yellow])[/color] + '">Link</a>');
</script>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top