Click to See Complete Forum and Search --> : call javascript from asp code


TroelsM
06-05-2004, 05:49 PM
maybe a silly question - but I think I have done this before but cant remember how ?

I have the following script and code in an .asp page
and would like to call the script from the asp code - can I do this

<script>
<!--
function CryptMailto(s) {
var n=0;
var r="";
for(var i=0;i<s.length;i++) {
n=s.charCodeAt(i);
if (n>=8364) {n = 128;}
r += String.fromCharCode(n+(2));
}
return r;
}
// -->
</script>

</head>
<body bgcolor="#FFFFFF">

<%
text = "mailto:"
text = text & "troels@majlandt.dk"
' here I would like to call the CryptMailto function and return then result in the textcrypt - and the below method dosent work

textcrypt = CryptMailto(text)

response.write "<br>text after " & textcrypt
%>

any one know how to do this

redijedi
06-05-2004, 05:58 PM
I'm not sure what you did in the past, but the concept is fundamentally impossible as it is explained. Javascript runs in the browser, ASP runs on the server, and never the twain shall meet (directly). You may have been using JScript, which can supplement any VBScript you are using in your ASP page. Apparently, if you specify Javascript, an ASP page will interpret it as JScript which can be interpretted by ASP on the server.

Check out this link (http://www.4guysfromrolla.com/webtech/052899-1.shtml). This is probably how you did it in the past, but its not javascript, as it were.

Notice, however, that the author specified the runat=server attribute that is specific to ASP and its ilk.