Hello Deanimal,

The "referer" http header is not compulsory for a web browser to send back to the server. It is merely a convention which is very convenient in many cases. However, there can be nasty side effects (like exposing semi secret urls from a linking intranet). There has been lots of discussion about this subject far beyond your question. What I recall is that IE implements some security mechanism where a transition from scheme (e.g. http to https) suppresses the referer header. Also, some proxy/firewall products can filter referer headers.

When I had the same kind of problems with a web form I implemented the following three staged solution:

  1. use http referer header in the script (server side); if that fails:
  2. use hidden form field, updated from Javascript (client side; this works around a filtering proxy); if that fails:
  3. use some reasonable default url. This can be a link to a help-page if there is no valid default.

Example of the Javascript hack (from memory, not tested):

<form name="myform" ...> <input type="hidden" name="ref" value="http://my/default"/> ... </form> ... <script type="text/javascript"> document.forms.myform.value = window.location.href; </script>
Update: rephrased the three steps to be more clear (hopefully).

--
Cheers, Joe


In reply to Re: Writing link on HTML page by joe++
in thread Writing link on HTML page by Deanimal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.