...

View Full Version : JS Redirect Not Working for IE



GHGAustin
07-21-2011, 04:03 PM
I have data pages in my e-commerce site (from 1999) that are imbedded in a parent page using the object tag. I have started to include a little JS snippet that is intended to redirect to the parent if the embedded pages are loaded separately:



<script language="JavaScript" type="text/javascript">
try { if (top == self) {top.location.href='parentpage.htm'; } } catch(er) { }
</script>


This works fine in Firefox, but in IE 7 and 8 it gets into an infinite loop of reloading the parent page into the object frame.

Here is a sample:
http://www.greathallminis.com/Ancient_15mm/darkages_anc15_mm.htm

(I've left this page with the issue, while I have excluded the script for IE elsewhere.)

Is there an alternative and equally simple script for IE, or can I modify this to work for IE?

Thanks,

Rob

Lerura
07-21-2011, 08:57 PM
<script language="JavaScript" type="text/javascript">
if (location.href == top.location.href) {top.location.href='parentpage.htm';}
</script>

GHGAustin
07-22-2011, 05:13 AM
<script language="JavaScript" type="text/javascript">
if (location.href == top.location.href) {top.location.href='parentpage.htm';}
</script>

Hi!

Thanks for the try, Lerura, but that still seems to do the same thing. I have your script installed on:

http://www.greathallminis.com/Ancient_15mm/darkages_anc15_mm.htm

For IE8 it is still doing the infinite loop into the object.

GHGAustin
07-25-2011, 07:39 PM
Ah, well. On to another forum, I guess.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum