473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

The confirmbox does not cancel the link behavior

I used the following javascript to add confirm-boxes to links. The
confirm-boxes are added at runtime for links with the class "delete".

The script adds the function to the links. When I click the link, the
confirm box i shown. But then it breaks; no matter if I press Cancel og
Ok, there is the same behavior => the link is followed. I wonder why
that is - off course I don't want to follow the link, if I select
Cancel.

var confirmboxes = {
init: function() {
confirmboxes.apply("delete");
},
apply: function(sClass) {
var elements =
YAHOO.util.Dom.getElementsByClassName(sClass, "a",
"content");
if (!elements) return;
var n = elements.length;
for (var i=0; i<n;i++) {
YAHOO.util.Event.addListener(elements[i],
"click", function() {
return confirm("Er du sikker?");
});
}
return false;
},

}
YAHOO.util.Event.addListener(window, "load", confirmboxes.init);

May 28 '06 #1
5 1655
ls******@gmail.com wrote:
<snip>
... . But then it breaks; no matter if I press Cancel
og Ok, there is the same behavior => the link is
followed. I wonder why that is - off course I don't want
to follow the link, if I select Cancel. <snip> var n = elements.length;
for (var i=0; i<n;i++) {
YAHOO.util.Event.addListener(elements[i],
"click", function() {
return confirm("Er du sikker?");
});

<snip>

You have not posted the code for - YAHOO.util.Event.addListener - so its
mechanism is unknown. However, it looks like it does not include a
mechanism for cancelling the default action of event handlers by
returning true/false from the event handling function. The best source
of information on cancelling default actions with this code is its
documentation.

Richard.
May 28 '06 #2
>You have not posted the code for - YAHOO.util.Event.addListener - so its
mechanism is unknown.


YAHOO.util.Event.addListener is documented here:

http://developer.yahoo.com/yui/docs/...til.Event.html

And the sourcecode is available here:

www.intraface.dk/yui/event/event.js

--
Lars Olesen

May 28 '06 #3
Lars wrote:
You have not posted the code for - YAHOO.util.Event.addListener
- so its mechanism is unknown.


YAHOO.util.Event.addListener is documented here:

<snip>

Are you proposing that I read hundreds, or even thousand, of lines of
code that I may never use myself just to answer a question here?

Richard.
May 28 '06 #4

ls******@gmail.com wrote:
I used the following javascript
snip var elements =
YAHOO.util.Dom.getElementsByClassName(sClass, "a",
"content");

snip YAHOO.util.Event.addListener(elements[i],
"click", function() {
snip

YAHOO.util.Event.addListener(window, "load", confirmboxes.init);


You might have good luck asking this on the Yahoo! UI mailing list.

http://developer.yahoo.com/yui/#support

Peter

May 29 '06 #5
> You might have good luck asking this on the Yahoo! UI mailing list.

Thanks.

--
Lars Olesen

Jun 2 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jonas | last post by:
This works fine in Win XP but does not work at all in Win 98. Private WithEvents objIExplorer As InternetExplorer I have to do it like this to get it to work in Win 98 Dim objIExplorer As...
6
by: bayram guzer | last post by:
hi everybody, i have very strange error. i can not see some of the asp pages on my browser. when i look from view source, all the source is there but browser does not show anything, just an empty...
8
by: ahaupt | last post by:
Hi all, I have to use some javascript to "click" a search button on my aspx page. The server side btnSearch_Click executes prefectly, but there's a Response.Redirect within the method, that...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
89
by: Cuthbert | last post by:
After compiling the source code with gcc v.4.1.1, I got a warning message: "/tmp/ccixzSIL.o: In function 'main';ex.c: (.text+0x9a): warning: the 'gets' function is dangerous and should not be...
4
by: howfuchs | last post by:
I have following code: <a href="javascript:void(0)" onClick="if(confirm('Please click Yes to proceed. Click No to cancel')){location.href='http://www.someurl.com';}">some link</a> Tests fine...
6
by: Rob Peterson | last post by:
Hi there, Does anyone know how to actually "abort" the event (component change) described in the following link. Apparently it's doable as mentined in the "Remarks" section but how....
4
by: martin | last post by:
Hello, Is there a way to make a kind of "cancel" button on a form? Suppose you accidently changed or overwrote some data in a form, then I'd like to leave this form at once and cancel any...
5
by: Steve | last post by:
In VB6 I have a screen the has a text box and a datagrid If I click the datagrid, the 1st event is to validate the textbox and then the 2nd event is a datagrid mousedown event. If a get an error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.