[thelist] rollover behaviour

James Aylard evolt at pixelwright.com
Tue Feb 10 10:01:18 CST 2004


Joshua Olson wrote:

> A few people have already responded to this question, but I want to
> suggest a solution that provides a way for non-JS enabled people to
> follow the back link as well:
>
> <a href="thepreviouspage.php" onclick="history.go(-1); return
> false;">Back</a>

    Of course, this assumes that there is a linear progression to the site
design that would allow you to hardcode the href value. Using classic ASP
for an example, one could also try:

<%
Function FnReferer
    Dim strReferer
    strReferer = Request.ServerVariables("HTTP_REFERER")
    If Trim(strReferer) = "" Then
        FnReferer = "Default.asp"
    Else
        FnReferer = strReferer
    End If
End Function
%>

<a href="<%= FnReferer %>" onclick="history.go(-1); return false">&lt;
Back</a>

    Of course, one could argue that the Javascript in this case is
superfluous, but there are cases where the two approaches won't provide the
same value.

> FYI, You can use a similar trick when you need a popup window:
>
> <a href="thepage.php" onclick="window.open(this.href, '_blank',
> 'width=xxx, height=xxx'); return false;" target="_blank">Go to
> page</a>

    I would also suggest using this.target instead of '_blank' as the second
argument in the window.open() method. You could also encapsulate this in a
separate function and simply pass the variables to it, which makes it more
extensible for use throughout the page (or several pages if placed in an
external javascript file).

James Aylard



More information about the thelist mailing list