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 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question force orphan into iframe on index.html

    Hi,

    I'm sure this has been asked a million times, but I can't find an example that I can make work.

    Note: I am not familiar with variables and javascript so I need it explained as "cut & paste" as possible

    I am trying to force my orphaned content pages to reload back into their iframe on my index.html page. EG if a search engine indexes a content page and some one clicks it in their results, it will then load and refresh itself into the main EXISTING frame in index.html

    <SCRIPT LANGUAGE="JavaScript">
    <!--
    if (top == self) self.location.href = 'http://www.staticfarm.com/index.html' target='iframe';
    // -->
    </SCRIPT>

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Please try the following example


    parent page

    PHP Code:
    <HTML>
    <
    HEAD>
    <
    TITLE>Document Title</TITLE>
    <
    script type="text/javascript">
    <!--

    loc="page1.htm" // default page loading into the iframe

    var str location.search;
    if(
    str != ""){
    loc=str.substring(1str.length)
    }

    function 
    load_frame(){
    document.body.style.overflow="hidden"
    document.getElementById('iframe1').src=loc
    }

    // add onload="load_frame()" to the opening BODY tag

    // -->
    </script> 

    </HEAD>
    <BODY onload="load_frame()">
    <h1>Parent Page</h1>

    <iframe id="iframe1" src="page1.htm"></iframe>

    </BODY>
    </HTML> 

    iframe pages


    PHP Code:
    <HTML>
    <
    HEAD>
    <
    TITLE>Document Title</TITLE>
    <
    script type="text/javascript">
    <!--
    if (
    self == top){
    var 
    url self.location;
    self.location "parent.htm?" url;
    }
    // -->
    </script> 
    </HEAD>
    <BODY>
    <h1>Page 1</h1>
    </BODY>
    </HTML> 
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hmm, no luck

    Thanks heaps for your help.

    I tried (repeatedly) to get that example to work, but to no avail.

    the 2 pages i am fiddling with are www.staticfarm.com/index.html
    and www.staticfarm.com/products/bias.html

    It seems that I am unable to figure out how to pass the URL from the original page into the iframe. The iframe is called further down the page.
    In HTML i would just href it with a target="iframe" in the link, but as this is being provided by a variable read from the URL i dont know how to call it up in the <iframe src=VARIABLE HERE> kind of context.

    Many thanks for your help.

    Cheers


  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    In your index page you need a semicolon after the call to load_frame() in the body tag

    onload="load_frame() ; MM_preloadImages('images/


    In the iframe pages you need this


    <script type="text/javascript">
    <!--
    if (self == top){
    var url = self.location;
    self.location = "index.htm?" + url;
    }
    // -->
    </script>

    Change index.htm to the name of the parent page if this is not correct.


    On a side note is better not to use the word iframe as the name and id of your iframe, use something like my_frame or even iframe1
    Last edited by Mr J; 04-17-2005 at 08:50 AM.
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #5
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Bingo!

    Mr J.

    Thou art truly a scholar and a legend.

    It seems that the changing of my iframe id / name and the addition of the semicolon has done the job.

    Thankyou so much!

    Cheers



  • #6
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    fine tuning

    That is working a treat for me.

    A couple of small questions though.

    1) can you mask the redirected URL? I'm getting the result of http://www.staticfarm.com/index.html...ucts/bias.html when the bias.html page reloads into its iframe.

    No big deal really, but it would look a bit slicker.

    2) in dreamweaver, when I insert

    <SCRIPT LANGUAGE="JavaScript" type="text/javascript">
    <!--
    if*(self*==*top){
    var*url*=*self.location;
    self.location*=*"http://www.staticfarm.com/index.html?"*+*url;
    }
    // -->
    </script>*

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    I am not sure if there is a cure for your 1st question but if I do come across one I will let you know.

    As for your second question, is part of the question missing?
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #8
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #9
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Mr J
    I am not sure if there is a cure for your 1st question but if I do come across one I will let you know.

    As for your second question, is part of the question missing?
    ahh yes.
    It dumped everything after the script tag closed.

    The question was:
    After the script above, dreamweaver claims my BODY tag is no longer valid. It says that it does not belong inside the tag it is in etc.

    If i delete the script all is good again. Is dreamweaver just being fussy?
    it is the same pages links as initally above if you wanted to see how I've done it. I thought I'd not closed a tag or script, but cant see any probs.

    Cheers.

  • #10
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    As I have never used DreamWeaver I am not sure but it could be being fussy.

    You could try moving the call to load_frame to the end of the onload and see if that makes a difference.


    <BODY onload="MM_preloadImages('images/Static-mouseover_06.jpg','images/Static-mouseover_07.jpg','images/Static-mouseover_08.jpg', 'images/Static-mouseover_09.jpg','images/Static-mouseover_10.jpg') ; load_frame()" bgcolor="#f3f3f3" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>


    The above should be all one line.
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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