Results 1 to 7 of 7

Thread: get browser width

  1. #1
    Join Date
    Jun 2012
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default get browser width

    i have a table with 3 td's , the one on center will be 1000px width
    so i need to split the remaining pixels for left and right <td>

    how can i do this with javascript?

    i am using this code to get the exact resolution

    HTML Code:
    <script>
    function getDocHeight() {
        var D = document;
        return Math.max(
            D.body.scrollHeight, D.documentElement.scrollHeight,
            D.body.offsetHeight, D.documentElement.offsetHeight,
            D.body.clientHeight, D.documentElement.clientHeight
        );
    }
    
    function getDocWidth() {
        var D = document;
        return Math.max(
            D.body.scrollWidth, D.documentElement.scrollWidth,
            D.body.offsetWidth, D.documentElement.offsetWidth,
            D.body.clientWidth, D.documentElement.clientWidth
        );
    }
    
    alert( getDocHeight() );
    alert( getDocWidth() );
    </script>
    <td><td width=1000px><td>

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,965
    Thanks
    16
    Thanked 305 Times in 304 Posts
    Blog Entries
    11

    Default

    I'm not sure why you'd need JavaScript to do this. If its to ensure a centered table with equal outer cells, I think CSS should be enough - you can set both outer td widths to 50% each and they should just take up the available space. Couple that with margin:auto; on the main table to center it (just to be safe, although that shouldn't be necessary) and the result should be a table with a fixed centre cell that is 1000px wide, with each outer cell taking up the remaining width, whatever that is. I haven't tested this exact theory, (currently on iphone) but from experience, that's what behaviour I predict.

    If you need more help, please provide a link to your page, with a more detailed description of the project and what/why you're trying to achieve what you've described.
    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
    Jun 2012
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    i need to do it this way to get the exact with from the members browser because the outer cells will be clickable , adding 50% then the center cell will also become clickable

    http://demo.rawcodes.net/

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,965
    Thanks
    16
    Thanked 305 Times in 304 Posts
    Blog Entries
    11

    Default

    Im sorry, but I dont understand. Why would the center cell become a clickable link based on a width measurement? If whatever is in the 2 outer cells contains the hyperlink(s), they should not encroach into the center cell; http://fofwebdesign.co.uk/template/_...-cell-1000.htm
    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

  5. The Following User Says Thank You to Beverleyh For This Useful Post:

    game (07-14-2013)

  6. #5
    Join Date
    Jun 2012
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    thanks will try this way, is there any chance to make when they click any area in the outer cells it redirects them to another url?

  7. #6
    Join Date
    Jun 2012
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    i was using this code from http://wordpress.org/support/topic/c...mage-clickable

    Code:
    #bglink{
      display:block;
      height:100%;
      width:50%;
      position:fixed;
      left:0;
      top:0;
      z-index:0;
      text-indent:-5000em;
      /* If you want to make only a part of background clickable,
         adjust height/width/left/top here. */
    }
    
    #page {
      position:relative;
      z-index:10;
    }

  8. #7
    Join Date
    Jun 2012
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    got it to work with <td onclick="window.location = 'index.html';">cell content</td>

Similar Threads

  1. Coordinate Width:Height Percentages for Images (Shrunk on Browser Resize)
    By questions in forum Looking for such a script or service
    Replies: 4
    Last Post: 05-24-2013, 06:57 PM
  2. chrome browser width error
    By ggalan in forum JavaScript
    Replies: 1
    Last Post: 10-18-2011, 07:52 PM
  3. ddlevelsmenu - minor issues on zoom and small browser width
    By semmel in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 08-26-2011, 08:44 PM
  4. Drop Down Tabs level 2 position moves depending on browser window width
    By weezie in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 06-24-2010, 12:39 AM
  5. Resolved Maximizing browser window content width
    By wineohe in forum Looking for such a script or service
    Replies: 3
    Last Post: 04-17-2009, 03:25 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
  •