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

    Cannot set height property with variable

    Hi,

    I read the height querystring value from a url in an .aspx page via javascript.

    I use the following javascript to read the height value:

    Code:
        <script type="text/javascript" language="javascript">
        
            var params = window.location.search.substring(1).split( '&' );
            var iheight;
    
            for( var i = 0, l = params.length; i < l; ++i ) 
            {
                var parts = params[i].split( '=' );
                switch( parts[0] ) 
                {
                case 'height':
                    iheight = parseInt( parts[1] );
                    alert(iheight);
                    break;
                }
            }
           //iheight = 2000;
           document.getElementById('searchIFrame').setAttribute('height',iheight); 
      
        </script>
    I have an iframe on the same page and I want to set the height of the frame to the height of the iheight variable

    <iframe src="link to page" id="searchIFrame" width="600" height="400" scrolling="auto" frameborder="1"></iframe>

    The problem that I have is that as soon as I hard code the iheight = 2000; variable then the frame grows, but when I use the variable from the querystring then I cannot set the height property. In other words:

    document.getElementById('searchIFrame').setAttribute('height',iheight);
    Is NOT working

    , but

    document.getElementById('searchIFrame').setAttribute('height',2000);
    Is working

    All I am trying to achieve is to set the height property of an inline frame when the form loads using a variable that I set getting the value from a querystring.

    Is there maybe there is another way to do this?

    Please help?

    Thanks

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    How about
    Code:
    document.getElementById('searchIFrame').style.height=iheight+'px';
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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