Results 1 to 6 of 6

Thread: multiple iframe scripts not working

  1. #1
    Join Date
    Feb 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default multiple iframe scripts not working

    I hope someone on here can help me out.
    I have a script that I been using to load my iframe and resize to the window size. I been trying to add in a script that will allow me to make the Iframe target a content page but cannot get them both to run together correctly. Seams every script I try it overrides my resize script.

    The <head> script for resizing is:
    <script src="css/dw_viewport.js" type="text/javascript"></script>
    <script type="text/javascript">
    function setIframeHeight(id, h) {
    var main = document.getElementById(id);
    if (main) {
    var winHt = dw_Viewport.getWinHeight();
    main.style.height = Math.round( h * winHt ) + "px";
    main.style.marginTop = Math.round( ( winHt - parseInt(ifrm.style.height) )/2 ) + "px";
    }
    }

    window.onload = function() { setIframeHeight('main', .7); }
    window.onresize = function() { setIframeHeight('main', .7); }

    The <head> script for loading a new target page to iframe is:
    <script type="text/javascript">

    function loadIframe(){
    if (location.search.length > 0){
    url = unescape(location.search.substring(1))

    window.frames["main"].location=url
    }
    }

    onload=loadIframe
    </script>

    I use the external link to load my page with targeted iframe is:
    <a href="index.html?content.html">my content</a>

    My Iframe:
    <iframe name="main" id="main" src="index.html" allowtransparency="true" frameborder="0">Your browser doesn't allow viewing frames!</iframe>

    If someone has a better script or can show me how to apply these 2 script to run together id appreciate it.
    I have searched about adding multiple scripts but after trial and error I still didn't get any further.
    Thanks

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,933
    Thanks
    16
    Thanked 303 Times in 302 Posts
    Blog Entries
    9

    Default

    I think the easiest thing would be for you to post a link to the page in question. Although you've posted code fragments, it doesn't given us a picture of everything in context so its difficult to understand how everything is working together (or conflicting)

    Please also provide links to any scripts you've used, at the developers site/demo - there may be things there that have been overlooked.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Feb 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have saved 2 versions:
    http://www.panelsusa.com/index2.html (is what i started with has a resizing script for the iframe I found it at http://www.dyn-web.com/tutorials/iframes/fluid/)

    http://www.panelsusa.com/index3.html (is with the added targeting iframe script i found here at http://www.dynamicdrive.com/forums/s...-external-link) This script is preventing my original script for setting the iframe size.

    Thanks

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

    Default

    Replace onload=loadIframe with the following, then see what happens:
    Code:
    if ( typeof window.addEventListener != "undefined" )
        window.addEventListener( "load", loadIframe, false );
    else if ( typeof window.attachEvent != "undefined" )
        window.attachEvent( "onload", loadIframe );
    else {
        if ( window.onload != null ) {
            var oldOnload = window.onload;
            window.onload = function ( e ) {
                oldOnload( e );
                loadIframe();
            };
        }
        else
            window.onload = loadIframe;
    }

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

    Default

    I tested what I suggested in my previous post with the links you gave us. It works.

  6. #6
    Join Date
    Feb 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you molendijk for the code revision!
    It works perfectly, I since added a random text script to the page and had to add in a window.onload script to load the multiple scripts.
    Everything displays perfectly now!

Similar Threads

  1. Help with multiple tab scripts......
    By Bryguth3 in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 04-04-2011, 10:40 PM
  2. Multiple Scripts
    By aakinn in forum Dynamic Drive scripts help
    Replies: 6
    Last Post: 04-23-2009, 08:11 PM
  3. Multiple scripts in IE6
    By AndLincoln in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-23-2007, 08:58 AM
  4. Replies: 0
    Last Post: 06-16-2005, 03:16 AM
  5. Need Help Using Multiple Scripts
    By Audee2 in forum JavaScript
    Replies: 1
    Last Post: 09-22-2004, 01:21 PM

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
  •