---
title: "ff和ie通用div置右上角落"
author: "xxtianxiaxing"
date: "2009-03-24T08:31:07Z"
tags: []
slug: "ff-ie-div"
draft: false
lastmod: "2009-03-24T08:34:07Z"
id: 353897
url: "https://xylonwang.iteye.com/blog/353897"
---

```java

 <!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
window.onscroll=function(){
var aa = document.getElementById("divWatermark");
aa.style.top = document.documentElement.scrollTop+"px";
 
}
 
</script>
</head>
 
<body>
  <p>AAAAAAAAAAAAAAAAAAAAAAAAAA</p>
  <div id="divWatermark" style="position:absolute;top:0px;right:0px;width:150px;height:30px;background:#093;">Waterrark</div>     
  <p>AAABBB</p>
  <p>AAABBB</p>
   <p>AAABBB</p>
  <p>AAABBB</p>
    <p>AAABBB</p>
  <p>AAABBB</p>
    <p>AAABBB</p>
  <p>AAABBB</p>
    <p>AAABBB</p>
  <p>AAABBB</p>
    <p>AAABBB</p>
  <p>AAABBB</p>      
</body>
</html>








//判断中文字符串长度方法str.getBytes()得到的就是长度
String.prototype.getBytes = function() {    
	    var cArr = this.match(/[^\x00-\xff]/ig);    
	    return this.length + (cArr == null ? 0 : cArr.length);    
	}

```