Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with script for a website

    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.

    Cheers.

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    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?

  • #3
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey,

    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.

  • #4
    New Coder
    Join Date
    Dec 2006
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    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');
          if(theDiv.childNodes.length)
             theDiv.removeChild(theDiv.childNodes[0]);
          theDiv.appendChild(document.createTextNode(lastUrl));
        }
      },
      1000
    );
    The HTML for frame top

    Code:
    <div id="urllabel"></div>
    Last edited by vegu; 12-17-2006 at 05:25 AM. Reason: typos, im tired :|
    http://demo.vegui.org - vegUI AJAX framework
    http://www.landsofkazram.com - browser based graphical MMORPG

  • #5
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cheers for that, ill try it. If theres any one else with suggestions?

  • #6
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    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.
    Last edited by koyama; 12-17-2006 at 06:18 AM.

  • #7
    New Coder
    Join Date
    Dec 2006
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hrm, whoops! koyama is correct
    http://demo.vegui.org - vegUI AJAX framework
    http://www.landsofkazram.com - browser based graphical MMORPG


  •  

    Posting Permissions

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