• Jquery 随窗口改变大小不会影响浏览位置,DIV可以在绝对的位置不变.菜单相对位置不变


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Jquery 随窗口改变大小不会影响浏览位置,DIV可以在绝对的位置不变.菜单相对位置不变title>
    <meta name="Author" content="Geovin Du 塗聚文"/>
    <meta name="Keywords" content="捷为工作室"/>
    <meta name="Description" content="缔友计算机信息技术有限公司"/>
    
    <script type="text/javascript" src="http://www.dupcit.com/js/floating-1.7.js"></script>  
    <script language="javascript" type="text/javascript" src="http://www.dupcit.com/js/jquery.js"></script>
    <script language="javascript" type="text/javascript">
    $(window).resize(function() {   //alert("dsds");
    window.location.reload();
     }); 
    </script>
    
    </head>
    
    <body>
      <table  width="995" border="0" cellspacing="0" cellpadding="0" align="center" style="background-color:#CCCCCC;height:1100px;">
    			<tr>
    			<td width="300px;">.l;lpll;l;l;
    </td>
    				<td width="300px;">
    
    
    
    <div style="position:absolute;" id="dupcit">gegege</div> 
    
    
      </td>
    				
    				<td width="100px;"> </td>
    				<td> </td>
    			</tr>
    			<tr>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    				
    			</tr>
    			<tr>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    			</tr>
    			<tr>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    			</tr>
    			<tr>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    			</tr>
    			<tr>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    				<td> </td>
    			</tr>
    		</table>
    
    <div id="floatdiv" style="   
        position:absolute;   
        200px;height:350px;top:10px;right:10px;   
        padding:16px;background:#FFFFFF;   
        border:2px solid #2266AA;   
        z-index:100">   
    This is a floating javascript menu.  
        <div style="padding:16px">
            Just imagine. This could be your floating menu.
            <br/><br/>
            <a href="/" title="Go to the main page.">dupcit.com</a><br/>
            <a href="/javascript/blocks/" style="padding-left:15px">Building blocks scripts</a><br/>
            <a href="/javascript/forms/" style="padding-left:15px">Forms & validation</a><br/>
            <a href="/javascript/navigation/" style="padding-left:15px">Navigation scripts</a><br/>
            <a href="/javascript/window/" style="padding-left:15px">Window management</a><br/>
        </div>
     
    </div>   
      
    <script type="text/javascript">   
            var X1 = $('#dupcit').offset().top; 
           	var Y1 = $('#dupcit').offset().left;        	
    		document.write(X1+"<br />"); 
    		document.write(Y1+"<br />");
    		
        floatingMenu.add('floatdiv',   
            {   
                // Represents distance from left or right browser window   
                // border depending upon property used. Only one should be   
                // specified.   
                targetLeft: Y1,   
                //targetRight:    
      
                // Represents distance from top or bottom browser window   
                // border depending upon property used. Only one should be   
                // specified.   
                targetTop: 10,   
                // targetBottom: 0,   
      
                // Uncomment one of those if you need centering on   
                // X- or Y- axis.   
                // centerX: true,   
                // centerY: true,   
      
                // Remove this one if you don't want snap effect   
                snap: true  
            });   
    </script>  
    
    <script type="text/javascript"> 
    var X = $('#dupcit').offset().top; 
    var Y = $('#dupcit').offset().left; 
    document.write(X+"<br />"); 
    document.write(Y+"<br />"); 
    //获取相对(父元素)位置: 
    var C = $('#dupcit').position().top; 
    var D = $('#dupcit').position().left; 
    document.write(C+"<br />"); 
    document.write(D); 
    </script>
    
    </body>
    
    </html>
    

    注:IE下会出现死循环的更新,还是有BUG.可以把当窗体变化时加载窗体的代码注释.也可以另方法解决.
    哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)成功.---Geovin Du(涂聚文)
  • 相关阅读:
    POJ 2251 Dungeon Master
    HDU 3085 Nightmare Ⅱ
    CodeForces 1060 B Maximum Sum of Digits
    HDU 1166 敌兵布阵(树状数组)
    HDOJ 2050 折线分割平面
    HDU 5879 Cure
    HDU 1878 欧拉回路
    HDU 6225 Little Boxes
    ZOJ 2971 Give Me the Number
    HDU 2680 Choose the best route
  • 原文地址:https://www.cnblogs.com/geovindu/p/2047552.html
Copyright © 2020-2023  润新知