Alex Borsody
Alex Borsody

Reputation: 2040

Display message during cookie redirect

I have a site that saves a cookie to a users computer, when they next get to the homepage they are redirected to another page via a cookie.

I have tried using jquery loading() and document.write, to display a message during the 2 seconds that the page takes to redirect but none work, right now the only events that fire are alert() functions but those stop the page from loading. wWat is the best way to do this a popup?

jQuery will not work here it has to be a pure javascript solution because the message has to display before a jQuery selector can bind to the html, such as by using document.ready

Upvotes: 0

Views: 140

Answers (1)

Coenie Richards
Coenie Richards

Reputation: 568

No jQuery No Ready

<script>
  var cookie_name = 'cookie_name_to_check_for';
  if (document && document.cookie)
  {
      if (document.cookie.indexOf(cookie_name + '=') != -1)
      {
          document.write("<h1>loading...please wait</h1>");
          document.close();
          window.location.assign('http://google.com')
      }
  }
</script>

Upvotes: 1

Related Questions