View Full Version : Help with script for a website

12-17-2006, 02:25 AM
What code do i need, to copy how google show what the current url is in the top frame E.g: http://img255.imageshack.us/img255/2880/googleqw7.jpg

The layout of my site is exactly the same as. I want to be able to show what the url of the bottom frame is in the top frame.


12-17-2006, 03:32 AM
Hi toxicgtr,

Please explain a little more.

In Google Images, while one does see the URL of the bottom frame in the upper frame, it doesn't change dynamically as you continue browsing to other pages within the bottom frame, e.g. by clicking on links in the bottom frame.

It shows the URL of the initial page. Is this what you want? Or do you need the dynamic version that changes?

12-17-2006, 03:58 AM

I want the link to change every time someone clicks on a new link. So for example in the picture thats hosted the current page that i was on was "www.photoshopsupport.com/tutorials/cs2-photos" Say i clicked on the "tools" button on that photoshop website i would then want the link to display the correct url for that page e.g www.photoshopsupport.com/tools.html etc in the top frame. So i would need, as you say a dynamic version.:thumbsup:

12-17-2006, 04:20 AM
Im not aware of any event you could use on the main frame other than the onload event but thats not practical as it might get overwritten by the site that is loaded in the frame

However you could handle it with a timer i suppose, but im not the greatest fan of timers, so if any one knows a better way to handle this - via event preferably please let me know :)

Lets say we have frame_top , which is the top frame and frame_main which is the main frame where the user navigates in.+

frame_top and frame_name being the names of the frames as in name="frame_top"

Youd have a timer and a div element in the page that is loaded in frame_top, the div should have an id so you can access it easily.

The Javascript for frame_top:

lastUrl = '';
urlUpdate = setInterval(
function() {
if(parent.frames.frame_main.location.href != lastUrl) {

/* current url of frame_main is different from lastUrl, set lastUrl
* to current url

lastUrl = parent.frames.frame_main.location.href;

/* write the text to the frame by appending it to the div */

var theDiv = document.getElementById('urllabel');

The HTML for frame top

<div id="urllabel"></div>

12-17-2006, 04:24 AM
Cheers for that, ill try it. If theres any one else with suggestions?:thumbsup:

12-17-2006, 04:38 AM
We must however remember that we cannot pass the URL information from one frame to another unless they come from the same domain. For security reasons this is not allowed.

If frame contents are from 2 different domains it is not possible to have such a feature.

Not as far as I know anyway.

12-17-2006, 07:01 AM
hrm, whoops! koyama is correct :)