• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Running javascript in a JScript function?

I want to launch a javascript alert in all mailto links
in a website.  I'd like to create a JScript function that
I can include in my asp pages that takes an email address
and creates the mailto link and the javascript alert.  But I'm
little vague on how to go about this.

My script:
<% function EmailAlert(whoto){ %>

<a href="mailto:<%= whoto %>" name="theLink" onClick="return MailtoAlert(this)"><%= whoto %></a>

<SCRIPT LANG="JavaScript">
function doAlert(theLink)
      var sMessage = ''
      sMessage += 'Internet e-mail is uncertain.  By sending confidential or sensitive e-mail '
      sMessage += 'messages which are not encrypted you accept the risks of such uncertainty. '
                  
      var TF = confirm( sMessage );
    if ( !TF ) {
        alert ('Returning you to the previous page.')
          window.history.go(-1)
            }
}
</SCRIPT>
<%
}
EmailAlert("denam@fsr.com")
%>

This function is being included in a test asp page.  The browser
tells me there's an error on line 6, but I'm doubtful that
line 6 is the real problem.  Any suggestions?

thanks a bunch,
Dena
0
denam
Asked:
denam
  • 2
  • 2
1 Solution
 
helverCommented:
Does the fact that you're referencing the MailtoAlert function in your click handler and you've written a doAlert function have anything to do with the problem you're having?
0
 
denamAuthor Commented:
Hi Helver, it did, and a couple of other things.  
This is what I got working.

<% function EmailAlert(whoto){ %>

<a href="mailto:<%= whoto %>" onClick="return doAlert()">
<%= whoto %></a>

<SCRIPT LANGUAGE = "JavaScript">
function doAlert(){

var sMessage = ''
sMessage += 'Internet e-mail is uncertain.  By sending confidential or sensitive e-mail '
sMessage += 'messages which are not encrypted you accept the risks of such uncertainty. '

var TF = confirm( sMessage );
    if ( !TF ) {
    return false
    } else
    return true
}
</SCRIPT>
<%
}
%>

I don't mind giving you the points if you submit a question.

Dena
0
 
helverCommented:
If you feel like what I did suggested was worth 200 pts, then I'll happily take them... otherwise, it wouldn't hurt my feelings if you wanted to save those points for a more difficult question...
0
 
denamAuthor Commented:
Somehow, I ended up with a whole bunch of points.
It might be bad karma to be stingy with them.

cheers,
Dena
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now