Just include a check, like this:
if(prompt("Enter the complete URL for the link you wish to add.",
"http://")){
// Code here
}
else{
return false;
}
/Robert
-----Original Message-----
From: Karen Elliott [mailto:karen@v...]
Sent: den 6 november 2001 16:36
To: javascript
Subject: [javascript] cancel on prompt box
Hope someone can help. I've got a pop-up prompt box in a forum for inserting
the code for a hyperlink into the message where all the user has to do is
enter the web address. The problem is when I click cancel, it inserts "<a
href = null>null</a>". is there anyway to get it to insert nothing when
cancel is clicked? Here's the code I'm using:
function DoPrompt(action) {
var revisedMessage;
var currentMessage = document.form1.txtMessage.value;
if (action == "url") {
var thisURL = prompt("Enter the complete URL for the link you wish
to
add.", "http://");
var urlUBBCode = "<a href="+thisURL+">"+thisURL+"</a>";
revisedMessage = currentMessage+urlUBBCode;
document.form1.txtMessage.value=revisedMessage;
document.form1.txtMessage.focus();
return;
}
Any tips at all would help!
Thanks
Karen
_________________________
viplondon
9 St.Martins Court
London WC2N 4AJ
t-020 7379 6688
f-020 7379 6616
www.viplondon.com
__________________________________
The contents of this e-mail are intended for the named
addressee only. It contains information which may be of a
confidential and privileged nature. If you are not the intended
recipient, or authorised to receive it on their behalf, you may
not copy or use it, or disclose it to anyone else. We make
every effort to keep our systems virus-free. However, we
recommend that this e-mail and any attachments are
scanned for viruses as we can take no responsibility for any
computer virus which might be transferred by way of this e-
mail. If you received this e-mail in error please notify us
immediately and then destroy it.
_________________________