View Single Post
Old 26-02-2008, 17:18   #2
otarachi
Rìu Bạc
 
otarachi's Avatar
 
Tham gia: Aug 2007
Đến từ: Application Technology
Bài: 309
VZD: 12.444
Cảm ơn: 3
Điểm: 99/49 bài viết
Send a message via Yahoo to otarachi
Default

Theo lý thuyết thì FireFox và Opera không hỗ trợ innerText mà hỗ trợ textContent, IE thì ngược lại
Vậy ta sẽ viết 1 hàm kiểm tra nếu là IE thì sẽ dùng innerText còn nếu là FireFox,Opera thì sẽ dùng textContent
Code:
<html>
<head>
<title></title>
<script language="javascript">
function underfine ()
{
	var hasInnerText = (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
	var elem = document.getElementById('id');	

	if(!hasInnerText){
		window.open('http://'+elem.textContent,'_blank'); return false;	
	} 	
	else{
		window.open('http://'+elem.innerText,'_blank'); return false;	
	}
}
</script>
</head>
<body>
<a href="#" id="id" onClick="underfine()">www.google.com.vn</a>
</body>
</html>
bạn Customize lại theo ý mình nhé..
__________________
Phụ nữ thích nhiều thứ ở 1 người đàn ông
Đàn ông thích 1 thứ ở nhiều người phụ nữ
otarachi vẫn chưa có mặt trong diễn đàn   Trả Lời Với Trích Dẫn