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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Sam wrote:> 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.Stupid question: can you leave out the href entirely? Or does that break our good friend IE? Cheers, Ben -- Ben Kimball <mailto:zubin-mD4EcvzDNrj5xfTjtVVUew@public.gmane.org> Webmaster <phoneto:512.232.2195> Division of Continuing Education, UT Austin <walkto:SW7,203>
By the way if you want your href also to work (ie allow users to right click and open in new window) you might want to put some link in the href and attach a function dynamically to the anchor elements onDomLoad. ie, you could have <a href=''http://sam.com/rightclick.html'' class=''myClass''>Click here</a> And at the same, on dom load, you can get all anchor elements with myClass and listen to the clicks on it and make it go through your onClickHandler. Makes sense? Thanks, Mandy. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
The difference between <a> and <a href=""> is the first is an Anchor, while the second is a Link. If you want to link text but not have it be a ''link'', try putting <span></span> around the text and have your style/actions in that tag, including the mouseover effect. --William -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Ben Kimball Sent: Tuesday, August 15, 2006 9:36 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] Completely off-topic, so flame me Sam wrote:> 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.Stupid question: can you leave out the href entirely? Or does that break our good friend IE? Cheers, Ben -- Ben Kimball <mailto:zubin-mD4EcvzDNrj5xfTjtVVUew@public.gmane.org> Webmaster <phoneto:512.232.2195> Division of Continuing Education, UT Austin <walkto:SW7,203> _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.10.10/419 - Release Date: 8/15/2006 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.405 / Virus Database: 268.10.10/419 - Release Date: 8/15/2006
Couldn''t you just replace the href with javascript:void(0) on links that you are manipulating? This allows the link to function as expected when a user doesn''t have Javascript enabled and I think it should address your clients concern. Brandon On 8/15/06, William Attwood <WAttwood-uwF1JWZk6jFWk0Htik3J/w@public.gmane.org> wrote:> The difference between <a> and <a href=""> is the first is an Anchor, while > the second is a Link. If you want to link text but not have it be a ''link'', > try putting <span></span> around the text and have your style/actions in > that tag, including the mouseover effect. > > --William > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Ben > Kimball > Sent: Tuesday, August 15, 2006 9:36 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] Completely off-topic, so flame me > > Sam wrote: > > 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. > > Stupid question: can you leave out the href entirely? Or does that break our > good friend IE? > > Cheers, > Ben > > -- > Ben Kimball <mailto:zubin-mD4EcvzDNrj5xfTjtVVUew@public.gmane.org> > Webmaster <phoneto:512.232.2195> > Division of Continuing Education, UT Austin <walkto:SW7,203> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > -- > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.405 / Virus Database: 268.10.10/419 - Release Date: 8/15/2006 > > > -- > No virus found in this outgoing message. > Checked by AVG Free Edition. > Version: 7.1.405 / Virus Database: 268.10.10/419 - Release Date: 8/15/2006 > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Thanks everyone for your suggestions. I''m off to experiment. If I find anything useful, I''ll post back. Sam
"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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
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: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org[mailto:rails-spinoffs-> bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Thomas Fuchs > Sent: Tuesday, August 15, 2006 10:38 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
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: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs- >> bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Thomas Fuchs >> Sent: Tuesday, August 15, 2006 10:38 AM >> To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> >> _______________________________________________ >> Rails-spinoffs mailing list >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
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: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of Tom Gregory Sent: Tuesday, August 15, 2006 2:11 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.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: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs- >> bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Thomas Fuchs >> Sent: Tuesday, August 15, 2006 10:38 AM >> To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> >> _______________________________________________ >> Rails-spinoffs mailing list >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hi>- shift-click stuff shouldn''t break things >(probably doesn''t do what the user wants either, but...)Exactly that is also my problem. Oky not mine but also a customer of mine wants the shift click. Statement: Shift click does the same as click but opens in new window" Problem: I have some functionality that changes a area you could name display-area. The customer now argues that he expects the display-area in a new window. Any Ideas how to solve this? It seems that shift-clicking is not interceptable so that I can hook in my functionality to do something near useful Fabian -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Thomas Fuchs Sent: Dienstag, 15. August 2006 18:38 To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
> Exactly that is also my problem. Oky not mine but also a > customer of mine > wants the shift click. > Statement: Shift click does the same as click but opens in new window" > Problem: I have some functionality that changes a area you could name > display-area. The customer now argues that he expects the > display-area in a > new window.My thoughts: - Thomas'' statement: when onclick returns *false*, the href isn''t taken. That solves many problems and I think was overlooked by critics of the href=# option. - href="#" won''t go to the top of page if onclick returns false, however, href="javascript:void(0)" won''t go anywhere no matter what the onclick event handler returns. - IE will open a window in any case if the SHIFT key is held down. I''ve found no way to suppress this, except perhaps href="javascript:window.close" ;-) (think of the downside to this) - Regarding the overuse of links to reach an event handler: I am one of those coders who overuses links for onclick items which do not need to be "links". I do this believing it will be better for a screen reader to understand. I may be off on this, but a screen reader "knows" a link is clickable. I''m not sure it knows an <img> is clickable, especially if the onclick is assigned dynamically. - Regarding comments on designing links which behave well when JavaScript isn''t enabled: Some webs (e.g., the stuff we write) are run completely wrapped in a JavaScript portal, a.k.a. "Learning Management System". Designing links to perform favorably if JavaScript isn''t enabled don''t apply to our development work. The entire LMS would not run if JavaScript were not enabled.
I think you''ve misunderstood part of what I''m trying to say. (Sample file below.) On Firefox 1.5/OS X and Firefox 1.5/WinXP 1. When middle-clicking (or right-clicking and selecting "Open link in new tab"), a. The javascript does NOT fire, and b. The link opens in a new tab. So, if href="#", it opens a duplicate page, if href="javascript:void (0);" it opens a blank tab. 2. Oddly, when <alt>-clicking (to open in a new tab) a. The javascript DOES execute, and b. The link still opens in a new tab. In other words, as a Firefox user, I will often middle click on something that looks like a link--and the web app will not behave as I expect it to. Hence my suggestion to not use an href (and thus an <a> tag) at all if you''re trapping the onclick event but not linking anywhere. I''d also suggest trying to find a way to either make it not look like a link but still look clickable (is that a paradox?) or differentiate it visually somehow. It''s not just about "unobtrusive Javascript" or "HIJAX," it''s about behavior violating a user''s expectations. For added fun, try middle-clicking on "Link 3" in Firefox. On Safari 2.0, both when middle-clicking and <cmd>-clicking, and IE/ WinXP when <ctrl>- or <shift>-clicking, the javascript executes, but no new link/tab/window opens. (What I believe is expected behavior.) For both Safari and IE, right-clicking and selecting "Open link in new tab/window" does not execute the js, and opens the link in the new tab/window. -- TAG <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ TR/html4/strict.dtd"> <html> <head> <title></title> <script type="text/javascript"> //<![CDATA[ var Debug = { print: function (str) { if (!this.debug) {this.debug = document.getElementById("debug");} this.debug.innerHTML += str; }, println: function (str) {this.print(str + "<br />\n");} } var Event = { stop: function(event) { if (event.preventDefault) { event.preventDefault(); event.stopPropagation(); } else { event.returnValue = false; event.cancelBubble = true; } } } function click2() { var e = window.event; if (!e) {Debug.println("No event"); return false;} Event.stop (e); return false; } function click3(e) { Debug.println(''Link 3 clicked''); if (!e) {e = window.event}; if (!e) {Debug.println("No event"); return false;} Event.stop (e); return false; } window.onload = function () { var el = document.getElementById("link3"); el.onclick = click3; } //]]> </script> <style type="text/css"> #link3 { color:blue; text-decoration: underline; } </style> </head> <body> <ol> <li><a href="#" onclick="Debug.println(''Link 1 clicked''); return false;">Link 1</a></li> <li><a href="javascript:void(0);" onclick="Debug.println(''Link 2 clicked''); return click2();">Link 2</a></li> <li><span id="link3">Link 3</span></li> </ol> <pre id="debug"></pre> </body> </html> On Aug 15, 2006, at 12:47 PM, Sam wrote:>> Exactly that is also my problem. Oky not mine but also a >> customer of mine >> wants the shift click. >> Statement: Shift click does the same as click but opens in new >> window" >> Problem: I have some functionality that changes a area you could name >> display-area. The customer now argues that he expects the >> display-area in a >> new window. > > My thoughts: > > - Thomas'' statement: when onclick returns *false*, the href isn''t > taken. > That solves many problems and I think was overlooked by critics of the > href=# option. > > - href="#" won''t go to the top of page if onclick returns false, > however, > href="javascript:void(0)" won''t go anywhere no matter what the > onclick event > handler returns. > > - IE will open a window in any case if the SHIFT key is held > down. I''ve > found no way to suppress this, except perhaps > href="javascript:window.close" > ;-) (think of the downside to this) > > - Regarding the overuse of links to reach an event handler: I am > one of > those coders who overuses links for onclick items which do not need > to be > "links". I do this believing it will be better for a screen reader to > understand. I may be off on this, but a screen reader "knows" a > link is > clickable. I''m not sure it knows an <img> is clickable, especially > if the > onclick is assigned dynamically. > > - Regarding comments on designing links which behave well when > JavaScript > isn''t enabled: Some webs (e.g., the stuff we write) are run > completely > wrapped in a JavaScript portal, a.k.a. "Learning Management System". > Designing links to perform favorably if JavaScript isn''t enabled > don''t apply > to our development work. The entire LMS would not run if > JavaScript were > not enabled. > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I agree with the issues you describe below. These are real-world problems when designing web pages for general audiences. I doubt the inventors of "open in tab" and "open in new window" could foresee these issues. Sam> -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On > Behalf Of Tom Gregory > Sent: Wednesday, August 16, 2006 12:02 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails-spinoffs] Completely off-topic, so flame me > > I think you''ve misunderstood part of what I''m trying to say. (Sample > file below.) > > On Firefox 1.5/OS X and Firefox 1.5/WinXP > > 1. When middle-clicking (or right-clicking and selecting "Open link > in new tab"), > a. The javascript does NOT fire, and > b. The link opens in a new tab. > > So, if href="#", it opens a duplicate page, if href="javascript:void > (0);" it opens a blank tab. > > 2. Oddly, when <alt>-clicking (to open in a new tab) > a. The javascript DOES execute, and > b. The link still opens in a new tab. > > In other words, as a Firefox user, I will often middle click on > something that looks like a link--and the web app will not behave as > I expect it to. Hence my suggestion to not use an href (and thus an > <a> tag) at all if you''re trapping the onclick event but not linking > anywhere. I''d also suggest trying to find a way to either > make it not > look like a link but still look clickable (is that a paradox?) or > differentiate it visually somehow. It''s not just about "unobtrusive > Javascript" or "HIJAX," it''s about behavior violating a user''s > expectations. > > For added fun, try middle-clicking on "Link 3" in Firefox. > > On Safari 2.0, both when middle-clicking and <cmd>-clicking, and IE/ > WinXP when <ctrl>- or <shift>-clicking, the javascript executes, but > no new link/tab/window opens. (What I believe is expected > behavior.) > For both Safari and IE, right-clicking and selecting "Open link in > new tab/window" does not execute the js, and opens the link in the > new tab/window. > > > -- TAG > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ > TR/html4/strict.dtd"> > <html> > <head> > <title></title> > <script type="text/javascript"> > //<![CDATA[ > var Debug = { > print: function (str) { > if (!this.debug) {this.debug = > document.getElementById("debug");} > this.debug.innerHTML += str; > }, > println: function (str) {this.print(str + "<br />\n");} > } > > var Event = { > stop: function(event) { > if (event.preventDefault) { > event.preventDefault(); > event.stopPropagation(); > } else { > event.returnValue = false; > event.cancelBubble = true; > } > } > } > > function click2() { > var e = window.event; > if (!e) {Debug.println("No event"); return false;} > Event.stop (e); > return false; > } > > function click3(e) { > Debug.println(''Link 3 clicked''); > if (!e) {e = window.event}; > if (!e) {Debug.println("No event"); return false;} > Event.stop (e); > return false; > } > > window.onload = function () { > var el = document.getElementById("link3"); > el.onclick = click3; > } > //]]> > </script> > <style type="text/css"> > #link3 { > color:blue; > text-decoration: underline; > } > </style> > </head> > <body> > <ol> > <li><a href="#" onclick="Debug.println(''Link 1 clicked''); return > false;">Link 1</a></li> > <li><a href="javascript:void(0);" onclick="Debug.println(''Link 2 > clicked''); return click2();">Link 2</a></li> > <li><span id="link3">Link 3</span></li> > </ol> > <pre id="debug"></pre> > </body> > </html> > > > On Aug 15, 2006, at 12:47 PM, Sam wrote: > > >> Exactly that is also my problem. Oky not mine but also a > >> customer of mine > >> wants the shift click. > >> Statement: Shift click does the same as click but opens in new > >> window" > >> Problem: I have some functionality that changes a area you > could name > >> display-area. The customer now argues that he expects the > >> display-area in a > >> new window. > > > > My thoughts: > > > > - Thomas'' statement: when onclick returns *false*, the href isn''t > > taken. > > That solves many problems and I think was overlooked by > critics of the > > href=# option. > > > > - href="#" won''t go to the top of page if onclick returns false, > > however, > > href="javascript:void(0)" won''t go anywhere no matter what the > > onclick event > > handler returns. > > > > - IE will open a window in any case if the SHIFT key is held > > down. I''ve > > found no way to suppress this, except perhaps > > href="javascript:window.close" > > ;-) (think of the downside to this) > > > > - Regarding the overuse of links to reach an event handler: I am > > one of > > those coders who overuses links for onclick items which do > not need > > to be > > "links". I do this believing it will be better for a > screen reader to > > understand. I may be off on this, but a screen reader "knows" a > > link is > > clickable. I''m not sure it knows an <img> is clickable, > especially > > if the > > onclick is assigned dynamically. > > > > - Regarding comments on designing links which behave well when > > JavaScript > > isn''t enabled: Some webs (e.g., the stuff we write) are run > > completely > > wrapped in a JavaScript portal, a.k.a. "Learning Management System". > > Designing links to perform favorably if JavaScript isn''t enabled > > don''t apply > > to our development work. The entire LMS would not run if > > JavaScript were > > not enabled. > > > > > > > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
I tackled this problem with a history manager and the hash. So a user could actually bookmark a particular page or open a link directly by middle clicking and associate some javascript with a particular hash. It has worked extremely well thus far and the project that I did this on should launch soon. I based the history manager on the unFocus History Keeper. I will publish the work soon ... just haven''t had time. Brandon On 8/16/06, Sam <sam.google-Uc2IQQBAS6sAvxtiuMwx3w@public.gmane.org> wrote:> I agree with the issues you describe below. These are real-world problems > when designing web pages for general audiences. > > I doubt the inventors of "open in tab" and "open in new window" could > foresee these issues. > > Sam > > > > > -----Original Message----- > > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On > > Behalf Of Tom Gregory > > Sent: Wednesday, August 16, 2006 12:02 PM > > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > Subject: Re: [Rails-spinoffs] Completely off-topic, so flame me > > > > I think you''ve misunderstood part of what I''m trying to say. (Sample > > file below.) > > > > On Firefox 1.5/OS X and Firefox 1.5/WinXP > > > > 1. When middle-clicking (or right-clicking and selecting "Open link > > in new tab"), > > a. The javascript does NOT fire, and > > b. The link opens in a new tab. > > > > So, if href="#", it opens a duplicate page, if href="javascript:void > > (0);" it opens a blank tab. > > > > 2. Oddly, when <alt>-clicking (to open in a new tab) > > a. The javascript DOES execute, and > > b. The link still opens in a new tab. > > > > In other words, as a Firefox user, I will often middle click on > > something that looks like a link--and the web app will not behave as > > I expect it to. Hence my suggestion to not use an href (and thus an > > <a> tag) at all if you''re trapping the onclick event but not linking > > anywhere. I''d also suggest trying to find a way to either > > make it not > > look like a link but still look clickable (is that a paradox?) or > > differentiate it visually somehow. It''s not just about "unobtrusive > > Javascript" or "HIJAX," it''s about behavior violating a user''s > > expectations. > > > > For added fun, try middle-clicking on "Link 3" in Firefox. > > > > On Safari 2.0, both when middle-clicking and <cmd>-clicking, and IE/ > > WinXP when <ctrl>- or <shift>-clicking, the javascript executes, but > > no new link/tab/window opens. (What I believe is expected > > behavior.) > > For both Safari and IE, right-clicking and selecting "Open link in > > new tab/window" does not execute the js, and opens the link in the > > new tab/window. > > > > > > -- TAG > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/ > > TR/html4/strict.dtd"> > > <html> > > <head> > > <title></title> > > <script type="text/javascript"> > > //<![CDATA[ > > var Debug = { > > print: function (str) { > > if (!this.debug) {this.debug > > document.getElementById("debug");} > > this.debug.innerHTML += str; > > }, > > println: function (str) {this.print(str + "<br />\n");} > > } > > > > var Event = { > > stop: function(event) { > > if (event.preventDefault) { > > event.preventDefault(); > > event.stopPropagation(); > > } else { > > event.returnValue = false; > > event.cancelBubble = true; > > } > > } > > } > > > > function click2() { > > var e = window.event; > > if (!e) {Debug.println("No event"); return false;} > > Event.stop (e); > > return false; > > } > > > > function click3(e) { > > Debug.println(''Link 3 clicked''); > > if (!e) {e = window.event}; > > if (!e) {Debug.println("No event"); return false;} > > Event.stop (e); > > return false; > > } > > > > window.onload = function () { > > var el = document.getElementById("link3"); > > el.onclick = click3; > > } > > //]]> > > </script> > > <style type="text/css"> > > #link3 { > > color:blue; > > text-decoration: underline; > > } > > </style> > > </head> > > <body> > > <ol> > > <li><a href="#" onclick="Debug.println(''Link 1 clicked''); return > > false;">Link 1</a></li> > > <li><a href="javascript:void(0);" onclick="Debug.println(''Link 2 > > clicked''); return click2();">Link 2</a></li> > > <li><span id="link3">Link 3</span></li> > > </ol> > > <pre id="debug"></pre> > > </body> > > </html> > > > > > > On Aug 15, 2006, at 12:47 PM, Sam wrote: > > > > >> Exactly that is also my problem. Oky not mine but also a > > >> customer of mine > > >> wants the shift click. > > >> Statement: Shift click does the same as click but opens in new > > >> window" > > >> Problem: I have some functionality that changes a area you > > could name > > >> display-area. The customer now argues that he expects the > > >> display-area in a > > >> new window. > > > > > > My thoughts: > > > > > > - Thomas'' statement: when onclick returns *false*, the href isn''t > > > taken. > > > That solves many problems and I think was overlooked by > > critics of the > > > href=# option. > > > > > > - href="#" won''t go to the top of page if onclick returns false, > > > however, > > > href="javascript:void(0)" won''t go anywhere no matter what the > > > onclick event > > > handler returns. > > > > > > - IE will open a window in any case if the SHIFT key is held > > > down. I''ve > > > found no way to suppress this, except perhaps > > > href="javascript:window.close" > > > ;-) (think of the downside to this) > > > > > > - Regarding the overuse of links to reach an event handler: I am > > > one of > > > those coders who overuses links for onclick items which do > > not need > > > to be > > > "links". I do this believing it will be better for a > > screen reader to > > > understand. I may be off on this, but a screen reader "knows" a > > > link is > > > clickable. I''m not sure it knows an <img> is clickable, > > especially > > > if the > > > onclick is assigned dynamically. > > > > > > - Regarding comments on designing links which behave well when > > > JavaScript > > > isn''t enabled: Some webs (e.g., the stuff we write) are run > > > completely > > > wrapped in a JavaScript portal, a.k.a. "Learning Management System". > > > Designing links to perform favorably if JavaScript isn''t enabled > > > don''t apply > > > to our development work. The entire LMS would not run if > > > JavaScript were > > > not enabled. > > > > > > > > > > > > > > > > > > _______________________________________________ > > > Rails-spinoffs mailing list > > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >