Jump to content

Checking URL in seperate frame (pretty simple)


Submerged

Recommended Posts

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
Link to comment
Share on other sites

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 :)
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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 :)
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.