Hello,

I have been searching around the net looking for solutions to my problem, but none have worked. My issue is that when i redirect using:

<meta http-equiv="Refresh" content="0; url=<?php echo $URL; ?>"> 

The hash tag part of URL gets removed by IE. So example.com/sample#foo will just load as example.com/sample. This happens in all version of IE and appears to be a bug, but the question is how do I get around this issue?

Here is the redirect page template for wordpress that I am using:

<?php
/*
Template Name: Redirect
*/
?>

<?php if (have_posts()) : the_post(); ?>
<?php $URL = get_the_excerpt(); if (!preg_match('/^http:\/\//', $URL)) $URL = 'http://' . $URL; ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Refresh" content="0; url=<?php echo $URL; ?>"> 
</head>

<body>
</body>
</html>

<?php endif; ?>

I understand the hash tag is a client side thing so I have tried the following things with javascript in the head:

<script type="text/javascript">
var theurl = "<?php echo $URL;?>";
  // Redirect to hash if there is no hash in the URL.
  if (window.location.hash == '') {
    window.location.replace(theurl);
  }
</script>

OR just:

<script type="text/javascript">
  window.location.hash = window.location.hash;
</script>

None of these work, so I am thinking I might need to use a cookie method to solve this but I am unsure of how this would be implemented in my particular case.

Thanks in advance!

Messed around with the plugin a bit, but couldn't get anything to work. Any idea of how I would implement this on my redirect php page? So I've called the plugin file and now would I need to put some javascript in the head of the redirect php page?

I found out that there is actually a really simple solution to my problem. All I needed was a trailing slash before the hash. :/

example.com/sample/#foo instead of example.com/sample#foo

In the form tag add attibute onsubmit="window.location.reload()" for only IE

or you can add it with jquery

Sandeep: Nice try, but SIX YEARS too late.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.