PDA

View Full Version : encoding URL and mixing asp with js


nkamp
05-15-2006, 10:03 AM
Hello,

I have a URL with variable where in the & character is used (noord & oost). But the browser thinks that this is starting a new variable. Now I want to encode this variable.

.Write "openModalWin('info_popup_print_antemortem.asp?PROC_ID=" & Session("PROC_id") & "&BDRE_id=" & Session("BDRE_id") &"'+ExtraString, 0.95*screen.availWidth,0.95*screen.availHeight, 'yes');" & vbcrlf


In the javascript variable ExtraString are URL variables invoked.

Now I have three things:
1.

.Write "ExtraString = encodeURIComponent(ExtraString);" & vbCrLf

The URL is encoded but in the opened file the variable cannot be used anymore because the browser see it now as one variable

2. Mixing ASP en JS
I have tried to use & Server.URLEncode("%>+ExtraString+<% & ... But this is not working. Is this possible

3.
How to decode the URL? I have already the code where I have Request("URLvar") but I don't want to change every line of code like:
Request(decodeURIComponent("URLvar"). Is it possible that I decode my URL without the need to change the rest of my code?

Thanks in advance.

Nico

degsy
05-15-2006, 04:08 PM
Function URLDecode(str)
str = Replace(str, "+", " ")
For i = 1 To Len(str)
sT = Mid(str, i, 1)
If sT = "%" Then
If i+2 < Len(str) Then
sR = sR & _
Chr(CLng("&H" & Mid(str, i+1, 2)))
i = i+2
End If
Else
sR = sR & sT
End If
Next
URLDecode = sR
End Function