1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

can asp detect page height?

Discussion in 'C#' started by gilgalbiblewheel, Aug 8, 2007.

  1. #1
    Can asp detect the page height?
    because I want to resize the iframe where the page is nested in.
     
    gilgalbiblewheel, Aug 8, 2007 IP
  2. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #2
    I found this from
    http://www.w3schools.com/asp/showasp.asp?filename=demo_attributes
    <%
    dim fs,f
    set fs=Server.CreateObject("Scripting.FileSystemObject")
    set f=fs.GetFile(Server.MapPath("testread.txt"))
    Response.Write("The attributes of the file testread.txt are: " & f.Attributes)
    set f=nothing
    set fs=nothing
    %>
    Code (markup):
    I was wondering if this was changeable to detect the height of the file of the iframe src.
     
    gilgalbiblewheel, Aug 8, 2007 IP
  3. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #3
    ASP runs on the server side, whereas page-height is a client-side attribute. The suitable place to detect Pageheight will be JavaScript which runs on the client side.

    You can set values in Javascript and use them in ASP:

    <script type='text/javascript'>
    <!--
    document.cookie = "width=" + screen.width + ";";
    document.cookie = "height=" + screen.height + ";";
    //-->
    </script>

    Hope it helps.

    Kuldeep
     
    Kuldeep1952, Aug 11, 2007 IP
  4. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    Yeah that sounds interesting. Is there more to that?

    So the script above sets up cookies of width and height, right?
    And what asp script will retrieve it?
    Is there any tutorials on this?

    Thanks in advance.
     
    gilgalbiblewheel, Aug 11, 2007 IP
  5. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #5
    In ASP you can easily read the cookie values

    <%
    width=Request.Cookies("width")
    height=Request.Cookies("height")
    %>

    You can see a brief tutorial on asp cookies at w3schools
     
    Kuldeep1952, Aug 11, 2007 IP
  6. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #6
    It's worth a try thanks. But let's say the cookies are turned off then would this work?
     
    gilgalbiblewheel, Aug 11, 2007 IP
  7. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #7
    Of course it will not work. If the user has turned off the cookies in the his/her browser settings you will not be able to create them (cookies).
     
    yugolancer, Aug 13, 2007 IP
  8. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #8
    OK. The width and height shows 1280 X 768. Is that in pixels? How will the process work? How can I manipulate so that the height of the iframe will vary according to the height of the content?
     
    gilgalbiblewheel, Aug 13, 2007 IP
  9. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #9
    I am not sure what is your question actually but even if i understood wrong that the offered suggestion with the cookies is far away from any possible solution.
    You need to find the height of the CONTENT that you want to place inside iframe object which you want to set up that hight of the iframe is exactly the same as the height of the content. Therefore cookies has nothing to do with that.
    Correct me if i am wrong.
     
    yugolancer, Aug 13, 2007 IP
  10. shafferb1

    shafferb1 Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    This is almost impossible to be sure that it is accurate as it depends on browsers etc. I also suspect that if the content is larger than one screen then it will just give you the size of that screen.

    Ben Shaffer
     
    shafferb1, Aug 14, 2007 IP
  11. gilgalbiblewheel

    gilgalbiblewheel Well-Known Member

    Messages:
    435
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #11
    I have a page, the index.asp where right in the middle is an iframe that opens another page. I want the iframe to resize itself according to the content of the page within the iframe. Do you understand that so far?

    The reason for doing this is because I have div tags of advertisements right under the iframe and I don't want put a fixed height because either, when the content of the iframe is too little the bottom advertisements will be far away at the bottom. On the other hand when I place them higher when the iframe content changes it's size and become larger in height then the div tags are going to overlap the content of the iframe.

    How do I fix that problem?
     
    gilgalbiblewheel, Aug 14, 2007 IP
  12. yugolancer

    yugolancer Well-Known Member

    Messages:
    320
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    110
    #12
    I am not positive about the content. but, if you take the content from the testread.txt and it's probably text then you should probably count the lines and according that result set up the iframe height attribute.
     
    yugolancer, Aug 14, 2007 IP