alert(""What up dog"");") ...">

Calling JavaScript from ASP

I have a line of code:

Response.write("<script language=""text/JavaScript"">alert(""What up dog"");</script>")

      

This does not work. I don't see the warning box, but I can see that the page source wrote the code correctly:

<script language="text/JavaScript">alert("What up dog");</script>

      

What I am actually trying to do is this:

Response.write("<script language=""text/JavaScript"">document.cookie = '" & Cookie & " = ; expires=Thu, 01 Jan 1970 00:00:01 GMT;';</script>")

      

That is: Delete the cookie with the name stored in the ASP cookie variable. That won't work either, so I'm trying to create an alert box to check where I'm screwing up.

I tried deleting the cookie with pure ASP (Response.cookie (Cookie) .expires = Now () - 1), but since I created the cookie with JavaScript, it is not HTTPOnly, so I cannot access it by ASP. (I just found out about it, so I'm not 100% on why this is all, but here it is.)

So back to the first line of code, why can't I see a JavaScript alert box with this line of code? I'm clearly missing something simple (it's always something simple).

+3


source to share


1 answer


The attribute language=""

for <script/>

-tags has been deprecated and erroneous values ​​prevent scripting from being executed in many browsers.

It looks to me like you are heading towards an attribute type=""

.



Try using the following code:

Response.write("<script type=""text/javascript"">alert(""What up dog"");</script>")

      

+6


source







All Articles