Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,198,591 members, 7,968,710 topics. Date: Monday, 07 October 2024 at 11:43 AM |
Nairaland Forum / Science/Technology / Webmasters / Quick Javascript Pop Quiz (1079 Views)
How To Add A Pop-up On Your Wordpress Website / Most Confusing And Simple Maths Quiz / Dhtml Quiz: How Will You Detect If A Browser Support Javascript From Php Code? (2) (3) (4)
Quick Javascript Pop Quiz by yawatide(f): 11:14am On Nov 23, 2009 |
So, I see this a lot on various websites and it is quite annoying. Some Nigerian websites are no exception. Here is the scenario: A developer wants to have a popup on a page, upon onclick. Popup comes up fine but in FF (not too sure about IE since I rarely use it ), each time you click, even if the link/image/whatever is at the bottom of the page, the page always scrolls to the top. If you have encountered such and are like me, this can be quite annoying. The page should remain where it is and not scroll to the top. The code more often than not looks like so:
Technically, there is nothing wrong with the code above, except of course of the issue of scrolling to the top. Question? How would you modify the code above to prevent the page from always scrolling to the top? As always, I will wait for a few answers before answering, assuming no one has it right by then. Good luck! |
Re: Quick Javascript Pop Quiz by Nobody: 8:25pm On Nov 23, 2009 |
<a href="#" onclick="somePopUpFunction();return false;">click here</a> or <a href="javascript:void(0)" onclick="somePopUpFunction()">click here</a> |
Re: Quick Javascript Pop Quiz by yawatide(f): 8:55pm On Nov 23, 2009 |
that was too quick. why did you have to spoil the fun? I was thinking I would have to change the subject header to "site review" before I get a response Anyways, though both your solutions do the trick, #1 is preferred - some say that void(0) is invalid javascript and that if you check your console (FF. I haven't done this but take their word for it), void(s) generates an error as it returns "undefined" and it is possible that what you are clicking isn't undefined. Let me see if I can come up with something else |
Re: Quick Javascript Pop Quiz by Nobody: 2:58pm On Nov 24, 2009 |
sorry, i should not have spoilt the fun . . nice quiz sha |
Re: Quick Javascript Pop Quiz by kolitos007: 3:15pm On Nov 24, 2009 |
lol, that was excellent dhtml lol didn't even give us chance hehe |
Re: Quick Javascript Pop Quiz by Nobody: 5:09pm On Nov 24, 2009 |
i think yawa should have filtered me out. . .the answer is similar to one quiz yawa posted some time back. . something concerning links |
Re: Quick Javascript Pop Quiz by yawatide(f): 5:56pm On Nov 24, 2009 |
dhtml, so you cheated? |
Re: Quick Javascript Pop Quiz by Nobody: 10:39pm On Nov 24, 2009 |
^Now how did i cheat? |
Re: Quick Javascript Pop Quiz by yawatide(f): 11:37am On Nov 25, 2009 |
the answer is similar to one quiz yawa posted some time back. The above implies inside trading and in some countries, you, like bernie maddoff, would go to jail for a long time |
Re: Quick Javascript Pop Quiz by quadrillio(m): 1:21pm On Nov 25, 2009 |
DHTML, is not a cheat, he's just smart. yawa-ti-de: |
Re: Quick Javascript Pop Quiz by gozzilla(m): 6:04pm On Nov 29, 2009 |
See men yawning |
Re: Quick Javascript Pop Quiz by Nobody: 6:06pm On Nov 29, 2009 |
. . .strolling. . . |
Re: Quick Javascript Pop Quiz by remoranger(m): 9:18pm On Nov 29, 2009 |
strolling, scratching ma balls and chewing corn. |
Re: Quick Javascript Pop Quiz by yawatide(f): 9:40pm On Nov 29, 2009 |
remo: cold don catch you finish? You don score yet? |
Re: Quick Javascript Pop Quiz by remoranger(m): 11:28pm On Nov 29, 2009 |
@yawa it depends on your definition, lol. |
(1) (Reply)
Own A B2b Website Like Alibaba.com For Just N50,000.00 / Lucrativeness Of Website Design / The Story Behind Games.ng
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17 |