Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #31796 > unrolled thread
| Started by | bit-naughty@hotmail.com |
|---|---|
| First post | 2016-12-11 09:20 -0800 |
| Last post | 2016-12-15 09:22 +0700 |
| Articles | 10 — 5 participants |
Back to article view | Back to comp.lang.javascript
Button/link click not going anywhere bit-naughty@hotmail.com - 2016-12-11 09:20 -0800
Re: Button/link click not going anywhere Silvio <silvio@internet.com> - 2016-12-11 20:33 +0100
Re: Button/link click not going anywhere "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-12-12 00:08 +0100
Re: Button/link click not going anywhere JJ <jj4public@vfemail.net> - 2016-12-12 12:17 +0700
Re: Button/link click not going anywhere "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-12-12 12:15 +0100
Re: Button/link click not going anywhere JJ <jj4public@vfemail.net> - 2016-12-12 22:36 +0700
Re: Button/link click not going anywhere Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-12-12 20:37 +0100
Re: Button/link click not going anywhere bit-naughty@hotmail.com - 2016-12-14 09:36 -0800
Re: Button/link click not going anywhere "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-12-14 18:49 +0100
Re: Button/link click not going anywhere JJ <jj4public@vfemail.net> - 2016-12-15 09:22 +0700
| From | bit-naughty@hotmail.com |
|---|---|
| Date | 2016-12-11 09:20 -0800 |
| Subject | Button/link click not going anywhere |
| Message-ID | <01f1e8f6-21ff-4262-8748-ec52521d927f@googlegroups.com> |
If I have a button/link, upon clicking of which I do NOT want the browser to go off anywhere - ie. say, I want a text to be displayed/box to pop up, etc ,etc WITHOUT a refresh, (ie. the text just displays) what do I have to do? Thanks.
[toc] | [next] | [standalone]
| From | Silvio <silvio@internet.com> |
|---|---|
| Date | 2016-12-11 20:33 +0100 |
| Message-ID | <584daa24$0$1762$e4fe514c@newszilla.xs4all.nl> |
| In reply to | #31796 |
On 12/11/2016 06:20 PM, bit-naughty@hotmail.com wrote: > If I have a button/link, upon clicking of which I do NOT want the browser to go off anywhere - ie. say, I want a text to be displayed/box to pop up, etc ,etc WITHOUT a refresh, (ie. the text just displays) what do I have to do? > > > Thanks. > Click event on HTML <button> tag?. You can also give a "name" attribute to an <a> element instead of "href" and then handle the click event on it.
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2016-12-12 00:08 +0100 |
| Message-ID | <o2km9l$qt6$1@solani.org> |
| In reply to | #31796 |
On 11.12.2016 at 18:20, bit-naughty@hotmail.com wrote: > If I have a button/link, upon clicking of which I do NOT want the > browser to go off anywhere - ie. say, I want a text to be > displayed/box to pop up, etc ,etc WITHOUT a refresh, (ie. the text > just displays) what do I have to do? You should *prevent* the elements *default* action. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2016-12-12 12:17 +0700 |
| Message-ID | <kibk7dd211kg.1fiouohm77r6p$.dlg@40tude.net> |
| In reply to | #31796 |
On Sun, 11 Dec 2016 09:20:56 -0800 (PST), bit-naughty@hotmail.com wrote: > If I have a button/link, upon clicking of which I do NOT want the browser > to go off anywhere - ie. say, I want a text to be displayed/box to pop > up, etc ,etc WITHOUT a refresh, (ie. the text just displays) what do I > have to do? > > Thanks. For a link, set the HREF attribute to `javascript:void(0)`. For a button, if it's inside a FORM element, detach it from the form by not specifying the NAME attribute and not setting TYPE attribute to `submit`. If the button is not inside a FORM element, there's nothing need to be done. If you don't do these, you'll have to prevent the default action in your code yourself.
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2016-12-12 12:15 +0100 |
| Message-ID | <o2m0sf$iqh$1@solani.org> |
| In reply to | #31806 |
On 12.12.2016 at 06:17, JJ wrote: > On Sun, 11 Dec 2016 09:20:56 -0800 (PST), bit-naughty@hotmail.com wrote: >> If I have a button/link, upon clicking of which I do NOT want the browser >> to go off anywhere - ie. say, I want a text to be displayed/box to pop >> up, etc ,etc WITHOUT a refresh, (ie. the text just displays) what do I >> have to do? >> >> Thanks. > > For a link, set the HREF attribute to `javascript:void(0)`. See <http://pointedears.de/scripts/faq/cljs/#javascriptURI>, for why that may not be the best advice. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2016-12-12 22:36 +0700 |
| Message-ID | <1cknps6ke4f5s$.hwe6hkxull0r.dlg@40tude.net> |
| In reply to | #31812 |
On Mon, 12 Dec 2016 12:15:31 +0100, Christoph M. Becker wrote: > On 12.12.2016 at 06:17, JJ wrote: > >> On Sun, 11 Dec 2016 09:20:56 -0800 (PST), bit-naughty@hotmail.com wrote: >>> If I have a button/link, upon clicking of which I do NOT want the browser >>> to go off anywhere - ie. say, I want a text to be displayed/box to pop >>> up, etc ,etc WITHOUT a refresh, (ie. the text just displays) what do I >>> have to do? >>> >>> Thanks. >> >> For a link, set the HREF attribute to `javascript:void(0)`. > > See <http://pointedears.de/scripts/faq/cljs/#javascriptURI>, for why > that may not be the best advice. True, but OP doesn't want the browser to leave the current page, so there's no need for fallback. `HREF="javascript:void(0)"` would guarantee it without changing the current URL, when the link's click handler encounters an unhandled exception.
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2016-12-12 20:37 +0100 |
| Message-ID | <2568366.VdNmn5OnKV@PointedEars.de> |
| In reply to | #31815 |
JJ wrote: ^^ Please post using your real name here. > On Mon, 12 Dec 2016 12:15:31 +0100, Christoph M. Becker wrote: >> On 12.12.2016 at 06:17, JJ wrote: >>> For a link, set the HREF attribute to `javascript:void(0)`. >> See <http://pointedears.de/scripts/faq/cljs/#javascriptURI>, for why >> that may not be the best advice. > > True, but OP doesn't want the browser to leave the current page, so > there's no need for fallback. `HREF="javascript:void(0)"` would guarantee > it without changing the current URL, when the link's click handler > encounters an unhandled exception. You have not read the FAQ entry, have you? If there is no fallback, then an “a[href]” element should not have been used in the first place. Besides, the problem then is the unhandled exception. What actually happens is that the location of the window does change in that case, too, which is another reason why it is a bad idea (unless you make tests). -- PointedEars FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn/> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | bit-naughty@hotmail.com |
|---|---|
| Date | 2016-12-14 09:36 -0800 |
| Message-ID | <f4aef94c-eae6-4b5c-b332-00f3ae56dd24@googlegroups.com> |
| In reply to | #31806 |
On Sunday, December 11, 2016 at 11:17:23 PM UTC-6, JJ wrote: > If you don't do these, you'll have to prevent the default action in your > code yourself. How please? What needs to be done?
[toc] | [prev] | [next] | [standalone]
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Date | 2016-12-14 18:49 +0100 |
| Message-ID | <o2s0mt$hbc$2@solani.org> |
| In reply to | #31863 |
On 14.12.2016 at 18:36, bit-naughty@hotmail.com wrote: > On Sunday, December 11, 2016 at 11:17:23 PM UTC-6, JJ wrote: > >> If you don't do these, you'll have to prevent the default action in your >> code yourself. > > How please? What needs to be done? <https://lmgtfy.com/?q=javascript+prevent+default>. -- Christoph M. Becker
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2016-12-15 09:22 +0700 |
| Message-ID | <kpd4v8exavsx$.1aimoaxh48nbd$.dlg@40tude.net> |
| In reply to | #31863 |
On Wed, 14 Dec 2016 09:36:05 -0800 (PST), bit-naughty@hotmail.com wrote: > On Sunday, December 11, 2016 at 11:17:23 PM UTC-6, JJ wrote: > >> If you don't do these, you'll have to prevent the default action in your >> code yourself. > > How please? What needs to be done? It depends on how you handle the click event. So, please post the relevant code.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web