www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 03-29-2007, 07:31 AM
    gc40 gc40 is offline
    Registered User
     
    Join Date: Jan 2007
    Posts: 214
    Serious Issue with X Position

    Greetings All, I am using a script that places a new "popup" on my website when the page refreshes.

    The script works GREAT, but the only problem I have, is that people with different resolutions have the pop up displaying in the wrong places.

    The popup is meant to display outside of the website's <div> main container tag, or rather, to the right of the website itself.

    I am using a resolution of 1280x800 and I set the xposition to 1000 and it works great, but people using different resolutions get messed up results.

    How would I go about changing xposition to a percentage or soemthing? Solutions?

    p.s. Here is the actual script:

    Code:
    <script type="text/javascript">
    
    /***********************************************
    * Floating Top Bar script- © Dynamic Drive (www.dynamicdrive.com)
    * Sliding routine by Roy Whittle (http://www.javascript-fx.com/)
    * This notice must stay intact for legal use.
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    var persistclose=0 //set to 0 or 1. 1 means once the bar is manually closed, it will remain closed for browser session
    var startX = 1000 //set x offset of bar in pixels
    var startY = 5 //set y offset of bar in pixels
    var verticalpos="fromtop" //enter "fromtop" or "frombottom"
    
    function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
    
    function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) {
    offset += search.length
    end = document.cookie.indexOf(";", offset);
    if (end == -1) end = document.cookie.length;
    returnvalue=unescape(document.cookie.substring(offset, end))
    }
    }
    return returnvalue;
    }
    
    function closebar(){
    if (persistclose)
    document.cookie="remainclosed=1"
    document.getElementById("topbar").style.visibility="hidden"
    }
    
    function staticbar(){
    	barheight=document.getElementById("topbar").offsetHeight
    	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
    	var d = document;
    	function ml(id){
    		var el=d.getElementById(id);
    		if (!persistclose || persistclose && get_cookie("remainclosed")=="")
    		el.style.visibility="visible"
    		if(d.layers)el.style=el;
    		el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
    		el.x = startX;
    		if (verticalpos=="fromtop")
    		el.y = startY;
    		else{
    		el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight;
    		el.y -= startY;
    		}
    		return el;
    	}
    	window.stayTopLeft=function(){
    		if (verticalpos=="fromtop"){
    		var pY = ns ? pageYOffset : iecompattest().scrollTop;
    		ftlObj.y += (pY + startY - ftlObj.y)/8;
    		}
    		else{
    		var pY = ns ? pageYOffset + innerHeight - barheight: iecompattest().scrollTop + iecompattest().clientHeight - barheight;
    		ftlObj.y += (pY - startY - ftlObj.y)/8;
    		}
    		ftlObj.sP(ftlObj.x, ftlObj.y);
    		setTimeout("stayTopLeft()", 10);
    	}
    	ftlObj = ml("topbar");
    	stayTopLeft();
    }
    
    if (window.addEventListener)
    window.addEventListener("load", staticbar, false)
    else if (window.attachEvent)
    window.attachEvent("onload", staticbar)
    else if (document.getElementById)
    window.onload=staticbar
    </script>
    Reply With Quote
      #2  
    Old 03-29-2007, 07:31 PM
    disgracian disgracian is offline
    Lost Soul
     
    Join Date: Dec 2006
    Location: Samsara
    Posts: 155
    Change the variable startX to something like:
    Code:
    var startX=screen.availWidth-windowWidth;
    Where windowWidth would be the overall width of your pop-up window.

    Cheers,
    D.
    Reply With Quote
      #3  
    Old 03-29-2007, 10:59 PM
    gc40 gc40 is offline
    Registered User
     
    Join Date: Jan 2007
    Posts: 214
    Thank You.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 11:04 AM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.