Quick Question 2 - Webmasters - Nairaland
Nairaland Forum › Science/Technology › Webmasters › Quick Question 2 (721 Views)
| Quick Question 2 by yawatide(op): 6:58pm On Feb 25, 2009 |
So I have some time and have decided to post again, woohoo! ![]() So I am sure many of you are used to writing somethign like so: <a href="#" onclick="doStuff();">Click me</a> The problem is, in some browsers, clicking the link, even though it runs the javascript, causes the page to "jump" to the top, as though it were a "back to top" intra-link. Why? because it is trying to find the link and finding none, it resorts to the top. For me and perhaps you, I find this annoying. Question: how can you rewrite the code such that clicking the link will not only run the script but cause the page to stay where it is (and is supposed to be) without "jumping"? Responses are welcome ![]() |
| Re: Quick Question 2 by segsalerty(m): 8:55pm On Feb 25, 2009 |
![]() |
| Re: Quick Question 2 by Nobody: 9:16pm On Feb 25, 2009 |
![]() |
| Re: Quick Question 2 by segsalerty(m): 9:20pm On Feb 25, 2009 |
Pls DHTML SIR dont leave our poor souls stranded getting YAWA in Mrs YAWATIDE hands pls oooo , i beg bail us out ! its really something we've need to notice , Pls , let (we) young shall grow learn , I beg ooo ![]() |
| Re: Quick Question 2 by Nobody: 9:26pm On Feb 25, 2009 |
Erm segsa, maybe u can try <a href="javascript:doStuff()">Click me</a> - it may possibly work. or even <a href="javascript:void(0)" onclick="doStuff();">Click me</a> or <a href="javascript:void(0)"><span onclick="doStuff();">Click me</span></a> Have a nice day. |
| Re: Quick Question 2 by yawatide(op): 9:46pm On Feb 25, 2009 |
dhtml, so which is it? ![]() I don't recall saying my question was mutliple choice, he he. @all: If you don't understand the question, copy my code and paste it in a file of yours with a lot of content, such that it is at the bottom, then click the link. There is a solution, trust me. I will post it soon ![]() |
| Re: Quick Question 2 by Nobody: 9:49pm On Feb 25, 2009 |
Now, i did not recollect volunteering to answer the question. I was merely giving the students some codes to try out - as a kinda homework. I believe this solution should come from the students, not from me. Let us see if they are picking up from all dem tutorials going on. |
| Re: Quick Question 2 by segsalerty(m): 10:03pm On Feb 25, 2009 |
UHmmm, students? ![]() can any brilliant student help us out pls ? |
| Re: Quick Question 2 by yawatide(op): 10:14pm On Feb 25, 2009 |
hmmm, so dhtml, u dont c urself as a student? Interesting. Anyways, I await an answer. |
| Re: Quick Question 2 by yawatide(op): 10:35pm On Feb 25, 2009 |
Answer: <a href="#" onclick="doStuff(); return false;">Click me</a> - try it out in a multitude of browsers. Sure, javascript:void() will work, but only on certain browsers. Also, if on devices that disable javascript by default (think cell phones), such a link would not even work in the first place. Of course, you coud resort to using NOSCRIPT but why? I do have a question though: Why even bother having a "#" in the HREF to begin with? I mean, if you have no link, why put crap in there? Interesting question for which I have what I think is a good answer. See my next post coming soon, "Letz Learn Something: Graceful Degradation" ![]() |
Quick Question About GTB-TOKEN • Quick Question • Question 2: How To Prevent An Image From Storing In The Cache • 2 • 3 • 4
Web / Graphic Designer Needed Urgently • Help Me Install Wordpress On My Site • I Have A Job For You: Can You Build Web Application On Iphone?




