|
| Javascript vs. response.write Fra : Thomas Olesen |
Dato : 02-03-02 10:01 |
|
Hej
Jeg har problemer med at skrive et java script ud vha. response.write
jeg har testet nedenstående kode uden repsonse.write (hvor det virkede) -
Hertil skal siges at nogle af "'" er blevet sat ind i stedet for """ ellers
vil response.write ikke skrive det ud - Jeg tror det er der det går galt.
Hvad skal man gøre?
På forhånd tak for hjælpen
fancymarkerscript1() - bliver kaldt efter head-starttag
fancymarkerscript2() - bliver kaldt efter body-starttag
fancymarkerscript3() - bliver kaldt i body-starttag
<%
Function fancymarkerscript1()
response.write "<style>"
response.write ".spanstyle"
response.write "{"
response.write "position:absolute;"
response.write "visibility:visible;"
response.write "top:-50px;"
response.write "font-size:10pt;"
response.write "font-family:verdana;"
response.write "font-weight:bold;"
response.write "color:white;"
response.write "}"
response.write "</style>"
response.write "<script>"
response.write "var x,y"
response.write "var step=20"
response.write "var flag=0"
response.write "// Your snappy message. Important: the space at
the end of the sentence!!!"
response.write "var message='Velkommen til blablabla '"
response.write "message=message.split('')"
response.write "var xpos=new Array()"
response.write "for (i=0;i<=message.length-1;i++)"
response.write "{"
response.write "xpos[i]=-50"
response.write "}"
response.write "var ypos=new Array()"
response.write "for (i=0;i<=message.length-1;i++)"
response.write "{"
response.write "ypos[i]=-50"
response.write "}"
response.write "function handlerMM(e)"
response.write "{"
response.write "x = (document.layers) ? e.pageX :
document.body.scrollLeft+event.clientX"
response.write "y = (document.layers) ? e.pageY :
document.body.scrollTop+event.clientY"
response.write "flag=1"
response.write "}"
response.write "function makesnake()"
response.write "{"
response.write "if (flag==1 && document.all)"
response.write "{"
response.write "for (i=message.length-1; i>=1; i--)"
response.write "{"
response.write "xpos[i]=xpos[i-1]+step"
response.write "ypos[i]=ypos[i-1]"
response.write "}"
response.write "xpos[0]=x+step"
response.write "ypos[0]=y"
response.write "for (i=0; i<message.length-1; i++)"
response.write "{"
response.write "var thisspan =
eval('span'+(i)+'.style')"
response.write "thisspan.posLeft=xpos[i]"
response.write "thisspan.posTop=ypos[i]"
response.write "}"
response.write "}"
response.write "else if (flag==1 && document.layers)"
response.write "{"
response.write "for (i=message.length-1; i>=1; i--)"
response.write "{"
response.write "xpos[i]=xpos[i-1]+step"
response.write "ypos[i]=ypos[i-1]"
response.write "}"
response.write "xpos[0]=x+step"
response.write "ypos[0]=y"
response.write "for (i=0; i<message.length-1; i++)"
response.write "{"
response.write "var thisspan =
eval('document.span'+i)"
response.write "thisspan.left=xpos[i]"
response.write "thisspan.top=ypos[i]"
response.write "}"
response.write "}"
response.write "var timer=setTimeout('makesnake()',30)"
response.write "}"
response.write "</script>"
End Function
Function fancymarkerscript2()
response.write "<script>"
response.write "<!-- Beginning of JavaScript -"
response.write "for (i=0;i<=message.length-1;i++)"
response.write "{"
response.write "document.write('<span id='span'+i+''
class='spanstyle'>')"
response.write "document.write(message[i])"
response.write "document.write('</span>')"
response.write "}"
response.write "if (document.layers)"
response.write "{"
response.write "document.captureEvents(Event.MOUSEMOVE);"
response.write "}"
response.write "document.onmousemove = handlerMM;"
response.write "// - End of JavaScript - -->"
response.write "</script>"
End Function
Function fancymarkerscript3()
response.write "style='width:100%;overflow-x:hidden;overflow-
y:scroll' onLoad='makesnake()'"
End Function
%>
--
Thomas Olesen
| |
Mark S. Rasmussen (02-03-2002)
| Kommentar Fra : Mark S. Rasmussen |
Dato : 02-03-02 10:38 |
|
> Jeg har problemer med at skrive et java script ud vha. response.write
> jeg har testet nedenstående kode uden repsonse.write (hvor det virkede) -
> Hertil skal siges at nogle af "'" er blevet sat ind i stedet for """
ellers
> vil response.write ikke skrive det ud - Jeg tror det er der det går galt.
> Hvad skal man gøre?
> På forhånd tak for hjælpen
>
> fancymarkerscript1() - bliver kaldt efter head-starttag
> fancymarkerscript2() - bliver kaldt efter body-starttag
> fancymarkerscript3() - bliver kaldt i body-starttag
>
> <%
> Function fancymarkerscript1()
> response.write "<style>"
> response.write ".spanstyle"
> response.write "{"
> response.write "position:absolute;"
> response.write "visibility:visible;"
> response.write "top:-50px;"
> response.write "font-size:10pt;"
> response.write "font-family:verdana;"
> response.write "font-weight:bold;"
> response.write "color:white;"
> response.write "}"
> response.write "</style>"
>
> response.write "<script>"
> response.write "var x,y"
> response.write "var step=20"
> response.write "var flag=0"
> response.write "// Your snappy message. Important: the space at
> the end of the sentence!!!"
> response.write "var message='Velkommen til blablabla '"
> response.write "message=message.split('')"
> response.write "var xpos=new Array()"
> response.write "for (i=0;i<=message.length-1;i++)"
> response.write "{"
> response.write "xpos[i]=-50"
> response.write "}"
>
> response.write "var ypos=new Array()"
> response.write "for (i=0;i<=message.length-1;i++)"
> response.write "{"
> response.write "ypos[i]=-50"
> response.write "}"
>
> response.write "function handlerMM(e)"
> response.write "{"
> response.write "x = (document.layers) ? e.pageX :
> document.body.scrollLeft+event.clientX"
> response.write "y = (document.layers) ? e.pageY :
> document.body.scrollTop+event.clientY"
> response.write "flag=1"
> response.write "}"
>
> response.write "function makesnake()"
> response.write "{"
> response.write "if (flag==1 && document.all)"
> response.write "{"
> response.write "for (i=message.length-1; i>=1; i--)"
> response.write "{"
> response.write "xpos[i]=xpos[i-1]+step"
> response.write "ypos[i]=ypos[i-1]"
> response.write "}"
> response.write "xpos[0]=x+step"
> response.write "ypos[0]=y"
> response.write "for (i=0; i<message.length-1; i++)"
> response.write "{"
> response.write "var thisspan =
> eval('span'+(i)+'.style')"
> response.write "thisspan.posLeft=xpos[i]"
> response.write "thisspan.posTop=ypos[i]"
> response.write "}"
> response.write "}"
> response.write "else if (flag==1 && document.layers)"
> response.write "{"
> response.write "for (i=message.length-1; i>=1; i--)"
> response.write "{"
> response.write "xpos[i]=xpos[i-1]+step"
> response.write "ypos[i]=ypos[i-1]"
> response.write "}"
> response.write "xpos[0]=x+step"
> response.write "ypos[0]=y"
> response.write "for (i=0; i<message.length-1; i++)"
> response.write "{"
> response.write "var thisspan =
> eval('document.span'+i)"
> response.write "thisspan.left=xpos[i]"
> response.write "thisspan.top=ypos[i]"
> response.write "}"
> response.write "}"
> response.write "var timer=setTimeout('makesnake()',30)"
> response.write "}"
> response.write "</script>"
> End Function
>
> Function fancymarkerscript2()
> response.write "<script>"
> response.write "<!-- Beginning of JavaScript -"
> response.write "for (i=0;i<=message.length-1;i++)"
> response.write "{"
> response.write "document.write('<span id='span'+i+''
> class='spanstyle'>')"
> response.write "document.write(message[i])"
> response.write "document.write('</span>')"
> response.write "}"
> response.write "if (document.layers)"
> response.write "{"
> response.write "document.captureEvents(Event.MOUSEMOVE);"
> response.write "}"
> response.write "document.onmousemove = handlerMM;"
> response.write "// - End of JavaScript - -->"
> response.write "</script>"
> End Function
>
> Function fancymarkerscript3()
> response.write "style='width:100%;overflow-x:hidden;overflow-
> y:scroll' onLoad='makesnake()'"
> End Function
> %>
Der opstår problemer her fordi hele dit javascript bliver udskrevet på een
lang linie... Alle de steder hvor du normalt ville trykke på enter og gå til
næste linie skal du Response.Write VbCrLf.
Mvh Mark
| |
Jesper Stocholm (02-03-2002)
| Kommentar Fra : Jesper Stocholm |
Dato : 02-03-02 20:10 |
|
Mark S. Rasmussen wrote in news:a5q6ib$2n60$1@news.cybercity.dk:
[snip 130 linier]
>
> Der opstår problemer her fordi hele dit javascript bliver udskrevet på
> een lang linie... Alle de steder hvor du normalt ville trykke på enter
> og gå til næste linie skal du Response.Write VbCrLf.
>
behøvede du virkeligt at sende 130 linier med for at tilføje tre ?
Se evt om det at klippe det ikke-relevante væk på
http://www.usenet.dk/netikette/citatteknik.html
:)
--
Jesper Stocholm - http://stocholm.dk
Synes du også, at Britney trods alt er meget lækker - men dog
på grænsen til det kvalmende ? http://stocholm.dk/britney.txt
| |
Thomas Olesen (18-03-2002)
| Kommentar Fra : Thomas Olesen |
Dato : 18-03-02 22:03 |
|
On 02 mar 2002 Mark S. Rasmussen wrote:
>> response.write "document.write('<span id='span'+i+''
class='spanstyle'>')"
Takker for hjælpen - Det eneste problem er nu at den ikke vil fortolke
ovenstående kode, hvilket jo også er ganske forståeligt med alle de "'" jeg
har - Men hvad skal jeg gøre for at få hele linien skrevet ud og ikke kun
response.write "document.write('<span id=' ?
--
Thomas Olesen
| |
Jørn Andersen (18-03-2002)
| Kommentar Fra : Jørn Andersen |
Dato : 18-03-02 22:18 |
|
On 18 Mar 2002 21:02:58 GMT, Thomas Olesen
<thol_spamspameggandnospam_@mail.dk> wrote:
>>> response.write "document.write('<span id='span'+i+''
>class='spanstyle'>')"
>
>Takker for hjælpen - Det eneste problem er nu at den ikke vil fortolke
>ovenstående kode, hvilket jo også er ganske forståeligt med alle de "'" jeg
>har - Men hvad skal jeg gøre for at få hele linien skrevet ud og ikke kun
>response.write "document.write('<span id=' ?
Prøv med:
Response.Write "document.write(""<span id=""span'+i+'""
class=""spanstyle"">"")" & VbCrLf
- det bliver til:
document.write("<span id="span'+i+'" class="spanstyle">")
Good luck,
Jørn
--
Jørn Andersen,
Brønshøj
| |
Niels Prins (03-03-2002)
| Kommentar Fra : Niels Prins |
Dato : 03-03-02 00:45 |
|
In article <Xns91C565DE16E7CCORTHRAL@193.88.15.201>, Thomas Olesen
<thol_spamspameggandnospam_@mail.dk> wrote:
> <%
> Function fancymarkerscript1()
> response.write "<style>"
> response.write ".spanstyle"
........
Kan man ikke blot undvære response.write som man kan med html koder?
<%
Function fancymarkerscript1()
%>
noget javascript
<%
end function
%>
Niels
| |
|
|