Forum Moderators: open

Message Too Old, No Replies

bookmark

bookmark anchor

         

pznddq

4:53 pm on Nov 14, 2003 (gmt 0)



Hi,

For some reason the link keeps dropping the anchor bookmark.

<%
Function Leaving
Leaving = Request.QueryString("url")
If Leaving = "" Then
Leaving = Request.QueryString
Else
sBookmark = Request.QueryString("bookmark")
If sBookmark <> "" Then Leaving = Leaving & "#" & sBookmark
End If
End Function
%>

How can I change the code to add the bookmark to the end of the URL?

Regards,

PZNDDQ

Xoc

12:17 am on Nov 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You have got recursion going on. Since the name of the function is Leaving, every time you use Leaving inside the function, it is calling the function again to resolve the value. So the function is calling itself. Instead, you want to use a temporary variable, and only assign the return value at the end.

This is an important point when using a function in VBScript or Visual Basic. Don't use the return value as a variable--it just gets you into trouble.

<%
Function Leaving
strRet = Request.QueryString("url")
If strRet = "" Then
strRet = Request.QueryString
Else
sBookmark = Request.QueryString("bookmark")
If sBookmark <> "" Then strRet = strRet & "#" & sBookmark
End If
Leaving = strRet
End Function
%>