Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2006, 02:52 PM
Registered User
 
Join Date: Jul 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascript leftmargin adjustment based on browser.

Hi guys
   I'm trying the get my site to resize the left margin using triggers of screen resolution and type of browser, I've got it down for IE ok but firefox and opera need a larger leftmargin to centre the page. The code I have so far is:

onload call:

Code:
<body onLoad="MM_preloadImages('img/nav3448978125a.gif');checkRes()">
Javascript:

Code:
<script language = "javascript">
function checkRes()
{
    if (screen.width == 1024 && screen.height == 768)
    {
    document.getElementById("container").style.marginLeft = "5%"
    }

        if (screen.width == 800 && screen.height == 600)
        {
        document.getElementById("container").style.marginLeft = "15%"
        }
}
</script>
I've not managed to work out how to make browser specific changes to the margin, could anyone help?

Ben







Similar Threads
Thread Thread Starter Forum Replies Last Post
Browser Based Editor soumasreek ASP.NET 2.0 Professional 2 May 11th, 2007 05:42 PM
Folder Browser in javascript gupta_karan21 BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 0 December 15th, 2005 04:55 AM
VB .net or ASP(browser based) / suggestion/poll iniro VB.NET 2002/2003 Basics 3 September 26th, 2004 10:20 PM
Javascript Browser Sniffer 0.5 released paugq Javascript 0 May 27th, 2004 10:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.