Forums

ASP

This topic is locked

Javascript format in ASP response.write

Posted 09 May 2002 16:14:04
1
has voted
09 May 2002 16:14:04 Bob Vigen posted:
I got to have a open in new window inside my response.write code. But...

I dont know how to change the format of the javascript.

I have a runatserver with the whole html in response.write. Before the runatserver i have the javascript openwindow function.
I know when you use html you change the " to ' but what about javascript, what do you change the javascript ' to?

The code in looks like this now, but shows error. I guess the format is the problem.
Response.Write("<a href='#'onClick='MM_openBrWindow('help.asp','','resizable=yes,width=300,height=550')'><img src='../images/info.gif' width='21' height='21' border='0'></a>"

Replies

Replied 10 May 2002 03:18:59
10 May 2002 03:18:59 Hank Tan-Tenn replied:
The text you generate with your Response.Write statement is still HTML.

Instead of all the single quotes, substitute each double quote that normally occurs in HTML with TWO double quotes, like so:

Response.Write "<font color=""red"">whatever</font>"

Output:
<font color="red">whatever</font>

Edited by - akc on 10 May 2002 03:20:26
Replied 10 May 2002 10:08:55
10 May 2002 10:08:55 Bob Vigen replied:
But what about the single quotes in javascript that describe the url and window size?

Response.Write("<a href='#'onClick='MM_openBrWindow('help.asp','','resizable=yes,width=300,height=550')'><img src='../images/info.gif' width='21' height='21' border='0'></a>"
Replied 10 May 2002 14:15:48
10 May 2002 14:15:48 Hank Tan-Tenn replied:
Single quotes, including those used to enclose strings for the JS function, remain single quotes.

So I guess it would be:

Response.Write("<a href=""#"" onClick=""MM_openBrWindow('help.asp','','resizable=yes,width=300,height=550')""><img src=""../images/info.gif"" width=""21"" height=""21"" border=""0""></a>"

It's ugly and you need to test it to see if I haven't made a typo, but I think that's the idea.

Note: I also inserted a space between ='#' and onClick.

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
a href='#'onClick=
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Replied 10 May 2002 16:03:44
10 May 2002 16:03:44 Bob Vigen replied:
Thanks Akc!
Im working on this chat function, and the send botton will only work on clik, having to use the mouse each time can be irritating for the users.

Do you know how to get the send boton to work on "enter key".

The code looks like this now:
Response.Write("&lt;INPUT TYPE='BUTTON' NAME='buttonAct' VALUE='send' SIZE='4' ONCLICK='Act(this.form.Msg);'&gt;"

Thanks for your help and sory the trouble
Bob
Replied 10 May 2002 16:50:00
10 May 2002 16:50:00 Hank Tan-Tenn replied:
I don't use JS events much (and am in the middle of grad school exams), so hopefully someone else will give you suggestions.

What I do notice is ONCLICK. I think JS-related tags are more strict than typical HTML ones: so it needs to be onClick.

Good luck!
Replied 16 May 2002 13:14:07
16 May 2002 13:14:07 johannes nel replied:
u want 2 use the onkeypress event... the enter key's char code = 13 (i think... been awhile)


Reply to this topic