I just don't use links for anything other than things which are supposed to 
navigate you to somewhere else. It just seems weird for me to (when I turn off 
javascript) have a link sitting on the page doing nothing. 

So I do something like: 
<a href="/valid/link/here" onclick="equivelentDynamicStuff(); return false;">my 
link</a>

And it's always a valid link with or without javascript.

If I need click events where there isn't a link, for dynamic actions I'll 
handle it with something like:
<span onclick="moreDynamicStuff();">here we go</span>

This lets me reserve those ever precious links for navigation actions only. 
That way, even if you don't have javascript, things act the way you'd "expect" 
them to. Even if there's functionality you can't see.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Tom
Gregory
Sent: Tuesday, August 15, 2006 2:11 PM
To: rails-spinoffs@lists.rubyonrails.org
Subject: Re: [Rails-spinoffs] Completely off-topic, so flame me


I agree. As a "power user" who regularly opens links in multiple tabs  
any link to "nowhere" bothers me.  Even Thomas' solution doesn't  
behave properly on a middle-click, (or shift-click, or whatever OS- 
specific combination I need to open a link in a new tab).

If it must be a link, link it to something other than javascript.   
Otherwise, trap the onclick behavior, which can be done for any  
visible element.

Even better, do both, and use javascript to remove the now  
superfluous link.


TAG

On Aug 15, 2006, at 12:01 PM, Hill, Greg wrote:

> I'm going to go against the grain here and say I hate it when  
> people use
> # as the link.  It makes the browser jump to the top of the page,  
> and it
> adds a page to the history.  Maybe most people prefer that, but I'm  
> not
> one of them.
>
> Greg
>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
> [mailto:rails-spinoffs-
>> [EMAIL PROTECTED] On Behalf Of Thomas Fuchs
>> Sent: Tuesday, August 15, 2006 10:38 AM
>> To: rails-spinoffs@lists.rubyonrails.org
>> Subject: Re: [Rails-spinoffs] Completely off-topic, so flame me
>>
>> "If I hit Ctrl+Alt+Del the computer reboots!"
>>
>> Anyway, the accepted "normal" solution to this is:
>>
>> <a href="#" onclick="blablabla(); return false">bla</a>
>>
>> This makes sure:
>>
>> - page will validate, as "#" is a valid URL
>> - link doesn't do anything (expect for jumping to the top of the
>> page) when Javascript isn't active
>> - shift-click stuff shouldn't break things (probably doesn't do what
>> the user wants either, but...)
>> - "return false" makes sure the browser won't follow the link after
>> your JS stuff has run
>>
>> -Thomas
>>
>> Am 15.08.2006 um 17:23 schrieb Sam:
>>
>>>
>>> There's a lot of old-solutions to this problem lingering on Google,
>>> so it's difficult for me to determine if there's a more modern
>>> solution to this problem.  A customer posted a complaint yesterday
>>> about how I'm coding href's when an onclick event is used and the
>>> href should not be used.  It seems the complaint is that holding
>>> the shift key and clicking the link opens a new window pointing to
>>> javascript:void(0).
>>>
>>> Reminds me:  Doctor, it hurts when I hit my head with this
>>> hammer...  (don't hold the shift key and click might be a solution)
>>>
>>> href="#" // I never do this
>>>
>>> href="javascript:void(0)" // this is what I do, but I read void(0)
>>> is deprecated over null?
>>>
>>> should I use something else?
>>>
>>> Sam
>>>
>>>
>>> _______________________________________________
>>> Rails-spinoffs mailing list
>>> Rails-spinoffs@lists.rubyonrails.org
>>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
>>
>> _______________________________________________
>> Rails-spinoffs mailing list
>> Rails-spinoffs@lists.rubyonrails.org
>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> _______________________________________________
> Rails-spinoffs mailing list
> Rails-spinoffs@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to