johnnyg24 Posted February 22, 2010 Share Posted February 22, 2010 I'm trying to hide certain elements on a page IF a user just came from a specific page. I am trying to use ServerVariable("HTTP_REFERER") to store the previous page's URL. <input id="referingPage" type="hidden" value="<%=Request.ServerVariables ("HTTP_REFERER")%>" /> I then use some RegExp and Jquery to determine if it the previous page meets the criteria. $(document).ready(function() {var str = $('#referingPage').val() var lookFor = /sales/gi sales = lookFor.test(str) if(sales){ $('#sidenav').hide() }}) It works well in FF,Chrome and Safari but not IE.Can anyone tell me why? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 23, 2010 Share Posted February 23, 2010 What does IE send as the referer compared to the others? I.E., what is the value of the hidden input? Link to comment Share on other sites More sharing options...
johnnyg24 Posted February 23, 2010 Author Share Posted February 23, 2010 The reply is null. FF, Chrome and Safari return the previous pages URL, but not good old IE.I'm wondering if it has something to do with the $(document).ready(function(){}). Link to comment Share on other sites More sharing options...
jeffman Posted February 23, 2010 Share Posted February 23, 2010 First do a View Source. Look at the generated HTML to see what, if anything, appears in the actual text of your hidden tag. Or if that looks okay, alert the value of $('#referingPage').val() Link to comment Share on other sites More sharing options...
justsomeguy Posted February 23, 2010 Share Posted February 23, 2010 If IE doesn't send the referer then there's nothing you can do about that. There are some situations where browsers do not send a referer, or else it is up to the vendor's choice or options set by the user. You may have the referer disabled in IE. Some firewalls or security software will also strip the referer headers. Link to comment Share on other sites More sharing options...
johnnyg24 Posted February 24, 2010 Author Share Posted February 24, 2010 thanks guys. I've checked the source and even did an alert with the value and still nothing in IE. Any ideas on how to check which page a user just came from? Perhaps setting a session variable? Link to comment Share on other sites More sharing options...
justsomeguy Posted February 24, 2010 Share Posted February 24, 2010 Yeah, if they're coming from your site the easiest way is probably a session. In fact, if you're only interested in tracking your own site then a session would be much more reliable than the referer anyway. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.