Submerged Posted December 22, 2006 Share Posted December 22, 2006 I have a basic frameset, "top" and "bottom". I just need a script for the top window to wait about a half a second or a second, then check the location of the bottom frame. I have a link that loads in the bottom half, then gets redirected, and the top page is then supposed to read where the bottom one went to. Bonus points if you can get the URL into a PHP variable somehow :) Thanks for the help, I'm not very good at js.-Alex Quote Link to comment Share on other sites More sharing options...
fenway Posted December 22, 2006 Share Posted December 22, 2006 Could you explain that again? Quote Link to comment Share on other sites More sharing options...
Submerged Posted December 23, 2006 Author Share Posted December 23, 2006 Heh... sorry. Basically, I have 3 pages. Index.php is just a simple frameset that splits the page into 2 horizontal frames, named "top" and "bottom". The top frame shows the page "top.php", and the bottom shows the page "redirect.php".The twist is with the bottom page. That page, upon loading, then redirects to a new page. At that point (so, after a second or so for the new page to load), the top frame (top.php) needs to check the new location of the bottom frame, and put it into a variable. It would be great if that js variable could then be put into a php variable somehow, but I could work it with either.I hope that helps, and thanks for looking :) Quote Link to comment Share on other sites More sharing options...
fenway Posted December 26, 2006 Share Posted December 26, 2006 Well, you could always have a callback function called when the bottom frame finishes loading. Quote Link to comment Share on other sites More sharing options...
Submerged Posted December 27, 2006 Author Share Posted December 27, 2006 That solves the timing portion of it :) But how would I even assign the location to a url? I tried something like this:[code]<script>document.writeln(parent.bottom.location.href);</script>[/code]Which works, at least for a static page within my localhost where this runs on. However, if I load the frameset with a website (I tested with 'http://www.google.com') in the "bottom" frame, it doesn't work. Or, if I redirect from a local page (that normally works), to a real website, it also doesn't work. I'm not sure why, or how to fix it. Any ideas? Thanks!PS. If I redirect to a different local page, it still works. So I think it just gets screwed up when the bottom frame is a website on the actual internet, and not on my local server. Which is odd, and I have no clue why that would be the case. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 27, 2006 Share Posted December 27, 2006 I'm very confused... "assign the location of a url" with a document.write()? Quote Link to comment Share on other sites More sharing options...
Submerged Posted December 28, 2006 Author Share Posted December 28, 2006 That piece of code wasn't about assigning it to a variable, i was just trying to get it to print the location. If i could get it to successfully do that, then I could get it into a variable without a problem. Quote Link to comment Share on other sites More sharing options...
fenway Posted December 28, 2006 Share Posted December 28, 2006 And why can't you just set the .location? Quote Link to comment Share on other sites More sharing options...
Submerged Posted December 28, 2006 Author Share Posted December 28, 2006 I'm not trying to set a location - I'm trying to find the location of the bottom frame. Basically, I won't know what the URL is of the site in the bottom frame, so I am jsut trying to get the top frame to check the URL of the page in the bottom frame. It seems like it should be simple, but I've been searching Google for a few hours and I haven't found the answer. The above code works when its another page in my localhost, but if the bottom frame contains any site on a different server, it doesn't work. That's what I'm asking about. Thanks for any help :) Quote Link to comment Share on other sites More sharing options...
fenway Posted December 30, 2006 Share Posted December 30, 2006 I'm still not sure why you simply can't get at the .location attribute once it's loaded... Quote Link to comment Share on other sites More sharing options...
Submerged Posted December 31, 2006 Author Share Posted December 31, 2006 Here, try it, maybe you'll get a different result :)index.php[code]<html><frameset rows="50%,50%"> <frame src="top.php" name="top"> <frame src="http://www.google.com" name="bottom"></frameset>[/code]top.php[code]<?sleep(3);?><script>document.writeln(parent.bottom.location.href);</script>[/code]I added the sleep to make sure the bottom site loaded properly. If you put a local file in the bottom frame (i.e. "bottom.php"), it does print out "bottom.php on the top frame. With an actual site, such as http://www.google.com, it doesn't show anything. Is this just a limitation of javascript, or something I've coded wrong? Thanks! Quote Link to comment Share on other sites More sharing options...
fenway Posted December 31, 2006 Share Posted December 31, 2006 This is a cross-site scripting issue... you can't script across domains, and google is a different domain... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.