Jump to content

HTML in a style sheet


USER1

Recommended Posts

I need to insert a url link using CSS if this is even possibleas is done in a html file <a href="urltarget">linktext</a> but it needs to be inside a css file.It's for the firefox addon Stylish, I've hidden some elements but need to access some links in those elements that I can't single out, so I need to add them back manually.Cheers

Link to comment
Share on other sites

css is for styling only, javascript would be the best option, depends what element is hidden, taking guess here but if you have setup like below<style type="text/css">#hiddenelement{display:none;}</style><div id="hiddenelement"><a href="page1">page1</a><a href="page2">page2</a><a href="page3">page3</a></div>you could use javascript to access all links in hidden elment using<script type="text/javascript">function findme(){x=document.getElementById("hiddenelement");y=x.getElementsByTagName("a");for(i=0;i<y.length;i++){alert(y.href)}}window.onload=findme;</script>

Link to comment
Share on other sites

That might work if it had a tag, but all I have is a target url, there's no tag reference to single links.Maybe this will help, here's a copy of the div in question. I've bolded the only link that I need to be displayed.....<div id="navheader"> <div id="navheader_top"> <div class="navcontent"><a href="http://www.tagged.com/home.html" id="tagged_logo"><img class="png with_gold" src="http://x.tagstat.com/im/headers/default/logo_small.png" height="27" width="146"></a> <ul class="header_btm_links with_gold"><li><a href="http://www.tagged.com/home.html">Home</a></li><li><a href="http://www.tagged.com/profile.html" id="nav_profile">Profile</a><a href="#" id="nav_profile_dropdown" class="nav_dropdown"></a></li><li><a href="http://www.tagged.com/friends.html" id="nav_friends">Friends</a><a href="#" class="nav_dropdown" id="nav_friends_dropdown"></a></li><li><a href="http://www.tagged.com/find_groups.html" id="nav_groups">Groups</a><a href="#" class="nav_dropdown" id="nav_groups_dropdown"></a></li><li><a href="http://www.tagged.com/messages.html" id="nav_messages">Messages</a><a href="#" class="nav_dropdown" id="nav_messages_dropdown"></a></li><li><a href="http://www.tagged.com/browse.html">Browse</a></li><li><a href="http://www.tagged.com/search.html">Search</a></li> </ul> <ul id="account_options"><li><a href="http://www.tagged.com/account_info.html">account</a></li><li>|</li><li><a href="http://www.tagged.com/help.html">help</a></li><li>|</li><li><a href="http://www.tagged.com/logout.html">signout</a></li> </ul> </div> </div>

Link to comment
Share on other sites

are you asking for the link to only be shown in certain situations? based on some sort of login system? If you are using PHP and are using SESSION you could check to see if certain SESSION data is present and then display the link that way if it is or isn't.

Link to comment
Share on other sites

you can hide all the li tags using#navheader_top ul li {display:none;} or a tags using #navheader_top ul li a{display:none;} then you can assign a class or id to that li or a tag like so<li class="showme"><a href="http://www.tagged.com/logout.html">signout</a></li>or<a class="showme" href="http://www.tagged.com/logout.html">signout</a>then use.showme {display:block;}if you can't assign id or class and the link is the last linkfunction findme2(){x=document.getElementById("navheader_top");y=x.getElementsByTagName("li");y[y.length-1].style.display="block";}window.onload=findme2;EDIT: dont know what happen here but i lost 3/4 of my original posting

Link to comment
Share on other sites

I'm only using an external style sheet, I can't assign a tags or selectors to the source html, and javascript is not compatible with the css.Seems like it can't be done, but was worth a try. If anyone knows the best bet would have been here.I'll just stick to the way I've been logging out so far, with the bookmarked url.Thanks for the effort folks.JoN.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...