Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Alert before link is clicked
Old 03-22-2005, 09:42 AM Alert before link is clicked
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
Is there a way to attach a bit of javascript to OnMouseUp of a link (Can't use OnClick cos it's an ASP.NET LinkButton control) to ask the user if they're sure they want to continue?
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
 
Register now for full access!
Old 03-22-2005, 11:48 AM
Rufo's Avatar
Extreme Talker

Posts: 173
Trades: 0
I think that by the time the OnMouseUp event is fired, it is too late to stop the request (unless there is a command which does the equivalent of clicking the 'stop' button on the browser)

Rufo
__________________

Please login or register to view this content. Registration is FREE
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Old 03-22-2005, 12:36 PM
Kaiman's Avatar
Extreme Talker

Posts: 237
Trades: 0
Can you write an alert function that combines with the ASP.NET onclick event?

Also, if its just one link, how about using the onmouseover event?

Kaiman

Storm King Design
Kaiman is offline
Reply With Quote
View Public Profile
 
Old 03-22-2005, 04:50 PM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
I thought OnClick didn't fire until OnMouseUp did? Like, OnClick is actually a combo of both OnMouseDown and OnMouseUp happening on the same element. If that's true, OnMouseUp should work...

No idea about combining it with ASP.NET... the OnClick attribute of the asp:LinkButton component needs to have the name of an ASP.NET handler in it or it will complain. There might be a way to sneak it in after it's been rendered but no idea how. Come to think of it, I could use javascript to attach the events... provided ASP.NET generates predictable IDs.

Suppose I could use the OnClick event naturally, what would the code be?
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 03-22-2005, 04:58 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
HTML Code:
<a href="http://google.com" onclick="return confirm('Are you sure you want to continue?')">Link</a>
onclick is fired after both onmousedown and onmouseup have fired, so you could use either one I suppose. onclick is in response to a true click, (ie. button down - button up), while onmousedown is only in response to the down click, and onmouseup to the up. Thus, if a user clicks, holds, and then moves the pointer away from the object, the onclick event will not fire.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 03-22-2005, 06:26 PM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
OnMouseUp is fine. Only problem is if someone clicks off the link, moves onto the link, then releases, it will ask for a confirmation and then not do anything. I'm willing to risk that.

Chroder, that's exactly what I need except... it doesn't work. The link always fires.. that is in Firefox & Opera - works fine in IE... Guess I could make it an IE Only thing..
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by Minaki; 03-22-2005 at 06:29 PM..
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 03-22-2005, 07:40 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
onclick works, onmousedown or up does not.

Why not just use ASP.NET to add the onclick to your link? Something like this, perhaps:

Code:
<script language="C#" runat="server">
mylink.Attributes.Add("onclick", "return confirm('Are you sure you want to continue?')");
</script>
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 03-23-2005, 05:35 AM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
Didn't know you could do that. I'll try it in a bit...

OK it works, but not really - because I have the LinkButton in a DataGrid. If I move it out of the datagrid it's fine, but inside the datagrid it I get "Name 'cmdCancel' is not declared. ". Guess I'lkl have to read up on embedding controls in DataGrids... sure I've done something like this before so shouldn't be too hard...
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by Minaki; 03-23-2005 at 06:02 AM..
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Reply     « Reply to Alert before link is clicked
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.32832 seconds with 12 queries