Results 1 to 3 of 3

Thread: Sudden problem with IE and location ?

  1. #1
    Join Date
    Mar 2005

    Sudden problem with IE and location ?

    I've been using the following code without problems for the past 5 years or so to check that an iframe has been launched from its parent:

    	echo "<script type='text/javascript' language='javascript'>\n";
    	echo "if (top.location == location) {\n";
    	echo "location.href='./index.php?func=loggedout&q=1'\n";
    	echo "}\n";   
    	echo "</script>\n";
    Suddenly, in the past couple of days it's stopped working in some versions of IE which I'm guessing might be due to a javascript update that some users of the site have had while others haven't. No problems with Firefox, Chrome, Safari etc.

    Can anyone suggest why

      if (top.location == location)
    should no longer function as expected all of a sudden?

  2. #2
    Join Date
    Mar 2005
    update: was wondering if the problem might be resolved by using window.top.location and window.location instead? Will give it a go and see what happens.

    further update: appears to have made no difference, problem remains.
    Last edited by lxndr; 04-13-2013 at 01:14 AM.

  3. #3
    Join Date
    Feb 2006
    You'd be better off comparing top.location.href and location.href, since some browsers have a separate location object for top and child location objects, even it they have the same href. Two objects are never equal, even if they have all the same properties.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center