Results 1 to 6 of 6

Thread: Auto Resize Height Iframe Help!!!

  1. #1
    Join Date
    Mar 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Auto Resize Height Iframe Help!!!

    Hello Guys,

    I have spent days looking for a IFrame Auto Resize script that actually works!


    I came accross the Dynamic Drive SSII Script: http://www.dynamicdrive.com/dynamici...iframessi2.htm


    The problem with this script is that it doesnt take you to the top of the page.

    See Example: http://www.shopsignaturefashions.com/shop2.html


    The script works great resizing the i-frame, but if you are located at the bottom of a page, and you click on a link your page wont refresh to the TOP.


    Someone Help! Is there any modifications to the script to fix this problem!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    There is no reason why it should. If you want it to, you can do something about that. I am assuming that most of these links are on the page(s) in the iframe. If so do a:

    Code:
    <a href="whatever.php" onclick="parent.window.scrollTo(0,0);return true;">Link Text</a>
    If more than one layer of pages is involved, this might be better:

    Code:
    <a href="whatever.php" onclick="top.window.scrollTo(0,0);return true;">Link Text</a>
    If your link is on the top page:

    Code:
    <a href="whatever.php" onclick="window.scrollTo(0,0);return true;">Link Text</a>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Mar 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking window.scrollTo (modification)

    Thank you so much for your response!

    Is there a way to incorporate the script mentioned on the IFRAME Script.

    In another words, there is alot of links, and is PHP Pages, I can go in there and edit all those links manually.



    url: http://www.shopsignaturefashions.com/men.html


    So if there is a way to modified the code for IFRAME SSII From Dynamic Drive to automatically RESIZE PAGE, and SCROLL TO TOP Standard.

    <a href="whatever.php" onclick="parent.window.scrollTo(0,0);return true;">Link Text</a>
    If more than one layer of pages is involved, this might be better:

    Code:

    <a href="whatever.php" onclick="top.window.scrollTo(0,0);return true;">Link Text</a>
    If your link is on the top page:

    Code:

    <a href="whatever.php" onclick="window.scrollTo(0,0);return true;">Link Text</a>




    Thank you so much!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, first I'd try a few out manually to make sure it does the trick and to determine which code you want to use. I think that:

    top.window.scrollTo(0,0)

    will work in most situations. The only problem with that would be if there is another page on top of everything else including the page with the iframe on it.

    Once you've determined which code you like, you can make up a script to assign it to all links on a page:

    Code:
    (function(){
    	function add_to_links(){
    		function added_click(){
    		top.window.scrollTo(0,0);
    		return true;
    		}
    	var l=document.getElementsByTagName('a');
    	for (var i = 0; i < l.length; i++)
    	if ( typeof window.addEventListener != "undefined" )
    	l[i].addEventListener( "click", added_click, false );
    	else if ( typeof window.attachEvent != "undefined" )
    	l[i].attachEvent( "onclick", added_click );
    	}
    if ( typeof window.addEventListener != "undefined" )
    window.addEventListener( "load", add_to_links, false );
    else if ( typeof window.attachEvent != "undefined" )
    window.attachEvent( "onload", add_to_links );
    })();
    Save that to a file called add_links.js and put it in the root of your domain. Then on all pages where you want this done put this in the head:

    HTML Code:
    <script src="/add_links.js" type="text/javascript"></script>
    That will do it for virtually all modern browsers with javascript enabled.
    Last edited by jscheuer1; 03-24-2007 at 12:38 PM. Reason: cleanup and improve code
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Mar 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you!

    That works!

  6. #6
    Join Date
    May 2007
    Location
    Fort Hood, TX
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Another Option

    Quote Originally Posted by jscheuer1 View Post
    There is no reason why it should. If you want it to, you can do something about that. I am assuming that most of these links are on the page(s) in the iframe. If so do a:

    Code:
    <a href="whatever.php" onclick="parent.window.scrollTo(0,0);return true;">Link Text</a>
    If the pages that are going to be loaded into your iframe are local (on your site), then it would be easier to add the code on each of the pages to be loaded like so:

    Code:
    <body onload="top.window.scrollTo(0,0);return true;">
    Just a thought It's what I use on my site @ link removed (mature content)

    ".enoctis
    Last edited by jscheuer1; 05-12-2007 at 02:18 AM. Reason: Remove unnecessary link to mature content

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
  •