1

I've got a problem where I've got loads of child pages, and 1 main page that houses these subpages. The problem with that, being that the experience the application is trying to deliver needs to be nice and unified.

I have a menu that targets the iFrame to open URLs there, and I've got a bit of JS parent.document.title = document.title; that changes the parent's title, but one more thing I want to try and do, is to change the URL, similar to how Facebook does. If I'm on a friend's profile, the top and bottom bars don't move, but in Facebook's case it's an Ajax load - and the profile shows, and the URL changes to their profile ID without actually shifting from 1 page to another.

I've read in a couple of places that the parent.document.url value is read only to child frames, but I'm not very sure and this is something I've wanted to do for a while now!

Summarizing: Is there any way to change the parent's URL through a child iFrame? Similar to the code pasted above?

Thank You! Much appreciation for any answers :)

Karan
  • 267
  • 3
  • 8
  • 1
    Did you try `parent.location.href = 'http://www.google.com';` ? – Shai Mishali Nov 15 '11 at 10:33
  • Haha, yes - the problem with that is the URL I'm trying to set is what is being displayed in the iFrame, and so it takes me to the frame and puts me in an infinite loop of reloads D: I'm just trying to update the URL there to the relevant path as opposed to reloading the entire page. Thanks for your answer though! :) – Karan Nov 15 '11 at 10:38

1 Answers1

0

If I am not wrong, you are trying to simulate a back button effect. You can do this using window.location.hash Read: Location Hash for better idea.

Community
  • 1
  • 1
check123
  • 1,989
  • 2
  • 22
  • 28
  • This is 'kind of' what I want to do, except mixing it in with PHP as my navigation comprises of GET variables right now. :S I have an iFrame in my page, when I click a URL in that iFrame, that has a code to update the title, I'm trying to figure out a way to update the URL as well :S Thanks for your answer though :) – Karan Nov 15 '11 at 10:42
  • @Karan On a side note, Why not use ajax than iFrame(s)? – check123 Nov 15 '11 at 10:44
  • The load is far too big in this case and I'm going to be demo'ing the service, with a few hundred users simultaneously, my server's a load of rubbish and will probably destroy itself trying to run several load events simultaneously, the iFrames minimize that by causing a slight delay when the server's in use :) I can't get that to work with Ajax, haha. Edit* The other problem is that the loads are mostly PHP/MySQL which is even worse for Mr. Server. :( – Karan Nov 15 '11 at 10:48