You can't. You could do a onClick document.location change in JS, but thats totally ridiculous. <a href="link" >Anchor</a> isn't hard to do. Why are you so averse to it.
i mean.. if i have one link which is 5 times in a page then...? can we make it in CSS? i dont know whether css code contains any code for link!!
You can make a php function echoing the href 1 time, then call the function each place you need the link.
I think I understand what yogi wants to say... basically, when you want to give 5 div tags the same style, you would use a css class. So, if you want to give 5 a tags the same href, you would also use css. In case of links, you cannot use CSS. simply put the same href 5 times. thats the best way to do it.
Hi, In CSS you couldn't remove href, but in javascript you can using code like this: <script language="javascript"> function f() { window.open('name.htm','width=500,height=400,resizable=yes'); } </script>
i think you should use "href " and dont use java script because it has against the seo, and better for internal backlinks.
i have submitted your code in a web page but i don't understand where to link with a button.can u please explain.........
you can use this Place this code in under </head> <script language="javascript"> function link(link) { document.location=link; } </script> Code (markup): link With out href : <span onclick="link('http://google.com')">Go to Google.com</span> Code (markup): Thanks , Geek Singh
Why would you? No, don't use javascript without compelling reason. Google's not the only visitor to worry about not supporting javascript. ??? Odd sentence structure; the meaning is unclear. You can always use html's linking. More silliness. That's not even a good javascript implementation. A span cannot obtain focus, so how does that woork from the keyboard? Where did you get that? gary
Ok Dude if u need access from keyboard use this : Javascript : <script language="javascript"> function link(link) { document.location=link; } </script> html : <input style="background:transparent; border-style:none" onclick="link('http://google.com')" type="button" value="Go to Google.com" />
Yes, there are any number of ways to use the keyboard, but I was commenting on that particular bit of coding. Now as to your version, it is another silly approach, using poorly structured, non-semantic html, that fails if javascript is either not supported or is disabled. If you want to do it correctly, study this bit that uses javascript to open the link in a new page. Without javascript, it still works, but not with the new page embellishment. N.B. I don't recommend anyone forcing a new page, but if you're going to mess with your visitor, you might as well do it correctly. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>misc tests</title> <style type="text/css"> /*<![CDATA[*/ body, html { margin: 0; padding: 0; font: 100% san-serif; } button:focus, a:focus { background-color: pink; color: blue; } /*]]>*/ </style> <script type="text/javascript"> //<![CDATA[ window.onload = function() { var links = document.getElementsByTagName("a"); for (var i = 0; i < links.length; i++) { var rels = links[i].getAttribute("rel"); if (rels) { var testpattern = new RegExp("external"); if (testpattern.test(rels)) { links[i].onclick = function() { return !window.open(this.href); } } } } } //]]> </script> </head> <body> <p><a href="http://example.com/" rel="external"><button>click or use [enter] key—example.com</button></a></p> <p><a href="http://google.com/" rel="external"><button>click or use [enter] key—google.com</button></a></p> <p><a href="http://debian.org/" rel="external"><button>click or use [enter] key—Debian.org</button></a></p> </body> </html> Code (markup): cheers, gary