Results 1 to 8 of 8

Thread: Redirecting External Links to Dynamic iFrame

  1. #1
    Join Date
    Mar 2007
    Location
    Montreal, Canada
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Redirecting External Links to Dynamic iFrame

    - Disclaimer 1: I am not a programmer, just a curious designer, so please take that into consideration in your replies.
    - Disclaimer 2: Despite all advices against it, I couldn't find a better solution to my website than using iFrame
    - Disclaimer 3: Before asking for help, I researched *several* forums and although I found people discussing similar issues, I was not successful at adapting their solutions to my needs.

    Gentlemen,

    I need your help implementing a method to intercept and redirect external links to a dynamic iframe. By "dynamic" iframe I mean an iframe whose SRC would be filled up in accordance to the external URL being intercepted and that it would resize its HEIGHT accordingly in order to avoid scroll bars.
    The function for resizing the iframe id="child" is already correctly implemented like so:
    Code:
    <script language="JavaScript">
    <!--
    function calcHeight()
    {
      //find the height of the internal page
      var the_height=
        document.getElementById('child').contentWindow.
          document.body.scrollHeight;
      //change the height of the iframe
      document.getElementById('child').height=
          the_height;
    }
    //-->
    </script>
    and the call
    HTML Code:
    <iframe src="/main/index.php" width="100%" onLoad="calcHeight();" height="1" marginheight="0" marginwidth="0" scrolling="no" frameborder="0" id="child">
    This what I have going on:

    - index.html => contains some content and the iframe id="child"
    - childpage1[...N].php => several PHP pages which I do not want to show up outside of the parent "index.html". These pages use clean URLs from CMS such as "http://mydomain.com/pages/this-is-a-child-page/". Users might click on external links from search engines, for instance, about an specific page such as "http://mydomain.com/pages/this-is-child-page-7/" which obviously would load the page "orphaned", outside "index.html" and that is exactly what I am trying to avoid.

    Based on what I have researched so far, the best way (please, correct me if I'm wrong) to deal with this would be implementing a test condition on the header of the PHP child pages to verify if they are on "top" or not (if they are already inside the "parent" object "index.html"). If FALSE, the page would load normally, if TRUE, a variable should be created to store the URL of the requested page and passed through the link to the page "index.html" which would be immediately called.

    In "index.html" there would be a script to collect the variable sent through the link (something like "http://mydomain.com/?var=http://mydomain.com/pages/this-is-child-page-7/") and break the text string apart, store a portion of PATHNAME (in this case, "/pages/this-is-child-page-7/) and use it to replace the current SRC of iframe id="child". Probably, there would have to be another testing function in this script to compare the variable passed from the "orphaned" PHP page against the current value of SRC in iframe id="child" to determine if any action is actually required.

    This "replacement" function would be called onLoad and if tested true would run and refresh the page with the proper value in the iframe SRC.
    All this should be accomplished while still making the iframe HEIGHT dynamically adjustable and show a "clean" URL in the browser, such as "http://mydomain.com".

    The potential issues I foresee is an infinite loop due to two onLoad queries (one for SRC, another for HEIGHT) in the parent and child objects, which might required a merge into a single script.

    As you can tell, I have an idea of what needs to be done but not a clue on how to get it done. Any help would be greatly appreciated.

    Thanks,

  2. #2
    Join Date
    Mar 2007
    Location
    Montreal, Canada
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ::bump::

    nobody?

  3. #3
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I don't understand the problem... I'm sorry. =/
    Jeremy | jfein.net

  4. #4
    Join Date
    Mar 2007
    Location
    Montreal, Canada
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Let me try to explain a little further then.

    The reason is that the parent page is a static page whose iframe will alternate between two different CMS engines, basically switching between two websites which are identically styled thus making the switch transparent to the user.

    To make this clearer, let's say i have two databases, one for joomla and another one for drupal, so this is how i need the external clicks to behave:

    - user clicks "http://mydomain.com/joomla/this-is-page-7", he gets sent to "http://mydomain.com/index.html" with the iframe containing "/joomla/this-is-page-7/".

    - user clicks "http://mydomain.com/drupal/this-is-page-10", he gets sent to "http://mydomain.com/index.html" with the iframe containing "/drupal/this-is-page-10/".

    Again, this behavior should be accompanied by proper resizing of the iframe's HEIGHT and keeping a clear URL in the browser. The clean URL is desirable but is the least important aspect of this whole enchilada.

    I would like to refer you to this link which I studied and tried to implement to my needs without success, as I am sure you will read it with different eyes than mine.

    I believe I need to share with you the reason why I am using an iframe to begin with.

    The index.html holds a banner containing a slow, long and cyclic animation. If I were to put this banner in the header of the index.php page currently being loaded inside the iframe (avoiding the use of an iframe altogether, just having index.php as the top object), every time the user navigated by clicking in the menu options, the whole page would reload, forcing the animation to restart, which is *unacceptable*. The solution I found was creating a static page to hold the banner and maintain its fluidity while the users can navigate anywhere within the website without causing interruptions.

    I hope I have made matters clearer instead of more confusing. Thanks,

  5. #5
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You would give the "a" a target of the name of the iframe. Example:
    Code:
    <a href="http://google.com" target="a">Hi</a>
    <iframe width="100%" height="100%" src="http://yahoo.com" name="a"/>
    Jeremy | jfein.net

  6. #6
    Join Date
    Mar 2007
    Location
    Montreal, Canada
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you, Nile, I wish it were that simple...

    If you could follow the discussion here, maybe you'll get what i mean.

    Thanks,

  7. #7
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Sorry, I still don't understand.
    Jeremy | jfein.net

  8. #8
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,314
    Thanks
    28
    Thanked 136 Times in 131 Posts
    Blog Entries
    29

    Default

    I posted a thread on something similar HERE, except that I don't use PHP.
    I think you're looking for something like it. There's a demo.
    The advantage of what you're looking for is that external scripts and styles won't get lost during 'inclusion'.
    ===
    Arie Molendijk.
    Last edited by molendijk; 01-27-2010 at 10:26 PM. Reason: Correction

Bookmarks

Posting Permissions

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