Bài đăng

Hiển thị các bài đăng có nhãn javascript

Using Javascript in CSS

HTC with IE body { behavior:url(script.htc); } script.htc XBL with Firefox body { -moz-binding: url(script.xml#mycode); } script.xml: alert("XBL script executed."); I think what you may be thinking of is expressions or "dynamic properties", which are only supported by IE and let you set a property to the result of a javascript expression. Example: width:expression(document.body.clientWidth > 800? "800px": "auto" ); detail here: http://stackoverflow.com/questions/476276/using-javascript-in-css

Những cách bo tròn góc

http://www.curvycorners.net/includes/examples/demo5.html This is the styling for the <div> on this page: margin: 0.5in auto; border: 0px solid #fff; color: #fff; width: 60%; padding: 20px; text-align: left; background-color: #33F; border: 3px solid #fff; background-image: url(backrepeat.jpg); background-repeat: repeat-x; -webkit-border-radius: 20px; -moz-border-radius: 20px; Note that the background repeats, and that the box is styled with a percentage value. http://www.izwebz.com/video-tutorials/nhung-cach-bo-tron-goc/

trim String & Strip HTML using JavaScript

My Code: Đã test và chạy rất ổn. /* Xóa khoản trắng trong chuổi */ function myBestTrim( str ){ var start = -1, end = str.length; while( str.charCodeAt(--end) /g; // Replace the tag return this.replace(matchTag, ""); }; /* Phương pháp thứ nhất Dùng vòng lặp Xóa những thẻ html không mong muốn có trong chuổi xuất ra. strx: chuổi muốn cắt chop: chiều dài tối đa của chuổi muốn xuất ra. kết quả trả về:strx */ function removeHtmlTag(strx,chop){ strx = myBestTrim(strx); if(strx.indexOf(" ")!=-1){ s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length); } } strx = s.join(""); } chop = (chop

Giá trị false trong javascript

The following values are always false: * false * 0 (zero) * "" (empty string) * null * undefined * NaN (a special Number value meaning Not-a-Number!) All other values are truthy, including "0" (zero in quotes), "false" (false in quotes), empty functions, empty arrays, and empty objects.

Lỗi chưa khởi tạo đối tượng trong javascript

Ví dụ: // object constructor function ObjectConstructor(a, b, c) { this.A = a; this.B = b; this.C = c; this.Total = a + b + c; } var obj = ObjectConstructor(1, 2, 3); alert(obj.Total); kết quả trả về không phải bằng 6 mà là chẳng có gì cả. Bởi đối tượng obj chưa được khởi tạo. có 2 cách sửa lỗi này: cách 1: var obj = new ObjectConstructor(1, 2, 3); cách 2: // object constructor function ObjectConstructor(a, b, c) { if (!(this instanceof arguments.callee)) { return new ObjectConstructor(a, b, c); } this.A = a; this.B = b; this.C = c; this.Total = a + b + c; } alert(obj.Total);

Bài rất hay về thiết kế website sử dụng cho tất cả các trình duyệt

Xem <a href="http://www.tjkdesign.com/articles/branching.asp">chi tiết ở đây</a> <h3> The issue with hacks inside styles sheets</h3> Embedding <acronym title="Cascading Styles Sheet">CSS</acronym> filters within a styles sheet may: <dl> <dt>- invalidate the sheet:</dt> <dd>some hacks are "safe", but the validator chokes on more than a few. </dd> <dt>- create unecessary declarations:</dt> <dd>a declaration that targets a <i>single</i> browser is served to <i>all</i> <acronym title="User Agent">UA</acronym>s. </dd> <dt>- create redundant declarations:</dt> <dd>a same attribute is used more than once with <i> different values</i> (see below). </dd> <dt>- create cryptic declarations and rules:</dt> <dd>For example, the <a class="outlink" href=...

BackGround trong suốt cho IE

Khai báo css: * html img, * html .png {  /* Tên class của div có background là ảnh png trong suốt */     position:relative;     behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none",         this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')",         this.src = "transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("','').replace('")',''),         this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')",         this.runtimeStyle.backgroundImag...

Fix IE6 Double Margin bug

Author: Alessandro Coscia The problem IE6 is famous for its ' ie6 double margin bug '. It occurs when you use float boxes. In certain cases the margin will redouble. You can find more info about this bug to Position is Everything . Solutions There are several solutions: Hack one-half margin value for IE/win only Set display: inline Use jquery.fixDoubleMargin.js (compatible with prototype, mootools and scriptaculous!!!) Solution: Use jquery.fixDoubleMargin.js I wrote this plugin to solve this problem. It is very simple to use: include the libraries between head tag My Code: <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="js/jquery.fixDoubleMargin.js" type="text/javascript"></script> <script src="js/jqbrowser-uncompressed.js" type="text/javascript"></script> using it: <script> var $j = jQuery.noConflict(); ...

Fix IE6 Double Margin(Box Model Hack) bug

Hình ảnh
Box Model Hack Author: Alessandro Coscia The problem IE doesn't implement the correct (standard) box model, so box appears with different dimensions in different browsers. W3C's standard explains the correct model to adopt: Box Model. This is a good image (coming from Wikipedia) to understand the problem: Solutions There are some solutions: Hack one-half margin value for IE/win only Set display: inline Use jquery.fixBoxModel.js (compatible with prototype, mootools and scriptaculous!!!) Solution: Use jquery.fixBoxModel.js I wrote this plugin to solve this problem. Solution: Use jquery.fixBoxModel.js I wrote this plugin to solve this problem. It is very simple to use: include the libraries between <head> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="js/jquery.fixBoxModel.js" type="text/javascript"></script> code using: <script> var $j = jQuery.noConf...

Sưu tầm một số code về window.onscroll

Sưu tầm một số code về window.onscroll #leftBar { position:fixed; top:0; left:0; width:200px; _position:absolute; _top:expression(0+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px'); } và một số khác tại trang này // Editing Instructions // 1. Change '#your_div_id' to whatever the ID attribute of your DIV is // 2. Change '175' to whatever the height of your header is, if you have no header, set to 0 /******************************** * (C) 2009 - Thiago Barbedo * * - tbarbedo@gmail.com * *********************************/ window.onscroll = function() { if( window.XMLHttpRequest ) { if (document.documentElement.scrollTop > 299 || self.pageYOffset > 299 && document.documentElement.scrollBottom > 100) { $('#sidebar_left').css('top',document.documentElement.scrollTop); $('#sidebar_right').css('top',document.documentElement.scrollTop); } ...

Tối ưu đoạn mã javascript

Thông tin chi tiết xem ở trang này. http://code.google.com/closure/ http://code.google.com/closure/templates/docs/helloworld_js.html download ứng dụng về rồi sử dụng như phần ví dụ của nhà phát triển.

setTimeout & setInterval in javascript

Chú ý khi sử dụng setTimeout ( expression, timeout ); var timeoutId = setTimeout ( expression, timeout ); clearTimeout ( timeoutId ); setInterval ( expression, interval ); var intervalId = setInterval ( expression, interval ); clearInterval(intervalId) Ví dụ: setTimeout ( "doSomething()", 5000 ); function doSomething ( ) { // (do something here) setTimeout ( "doSomething()", 5000 ); } Thì nên sử dụng setInterval ( "doSomething()", 5000 ); Note: 5 giây hàm này thực thi và lặp lại suốt cho đến khi bạn sử dụng hàm clearInterval để ngưng việc thực thi. còn setTimeout thực thi sau 5 giây và thực thi đúng một lần rồi tự ngưng. bạn có thể ngưng giữa chừng bằng hàm setTimeout

Tạo menu chính có submenu xuất hiện ở hàng dưới

Bạn down về chạy thử. Việc thêm thắc để có menu đẹp là do chính bạn. Thay đổi thuộc tính của thẻ <a> như hover link...v..v. <html> <head> <title>... test ...</title> <style type="text/css"> .glossymenu{ position: relative; padding: 0 0 0 5px; margin:0px; background:url(image/menu.gif) repeat-x bottom; /*tab background image path*/ height: 25px; list-style: none; } .glossymenu li{ float:left; border-right:#FFFFFF 1px groove; } .glossymenu li a{ float: left; display: block; color:#FFFFFF; text-decoration: none; font-family: sans-serif; font-size: 13px; padding:0 0 0 5px; /*5px = width of menu1*/ height: 25px; line-height: 25px; text-align: center; cursor: pointer; } .glossymenu li a span{ float: left; display: block; padding: 0 10px 0 8px; /*Padding ...

class in javascript

My Code: function MyClass(){} a = new MyClass(); a.text = "The sum is " a.num1 = 10; a.num2 = 20; b = new MyClass(); b.firstname = "Jason"; b.lastname = "Bourne"; function X(p){ if(p.num1!=null) alert(p.text +(p.num1 + p.num2)); else alert(b.firstname+" "+b.lastname); } X(a); X(b);

xem ảnh trong blogspot

add script in header src='http://teckzest.bravehost.com/jquery.js' src='http://teckzest.bravehost.com/main.js' #preview{ position:absolute; border:1px solid #ccc; background:#333; padding:5px; display:none; color:#fff; } using it: < a class="preview" href="http://www.blogger.com/yourlink.com">< img alt="gallery thumbnail" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCAF8jjT6tP4frBImpoWv8JHsfVUxLuLxHmJcLHQGY6CDH1qMZBtAK7g0JkJklZ1Ipx2cvEguSHukei8GBmrht7WzO8pIZi6I-_8U6r2xb5rXCNefHJ3mR1T88a2TnJLqYio2VLdUDi38/s320/1s.jpg" /></a>

Cách vào face book khi sử dụng bất cứ mạng nào

Cách thứ nhất: cách vào facebook mạng fpt hay bất kỳ mạng nào mở file C:\windows\system32\drivers\etc\hosts thêm vào cuối file dòng bên dưới: ############################################# 69.63.187.17 facebook.com 69.63.181.22 login.facebook.com 69.63.186.12 apps.facebook.com 69.63.187.17 www.facebook.com 69.63.181.22 www.login.facebook.com 69.63.186.12 www.apps.facebook.com ############################################# lưu file lại dzậy là OK rồi nhé. Cách thứ hai: ngoài ra còn có thể sử dụng OPENDNS. làm như sau: - Nhấn Start menu, chọn Control Panel. - Click đúp vào Network Connections. - Nhấp chuột phải vào Local Area Connection (nếu là dùng mạng LAN ADSL) hoặc chọn Wireless trong Network Connections, sau đó chọn Properties. - Chọn Internet Protocol (TCP/IP) và click Properties. - Trong cửa sổ hiện ra, chọn mục “Use the following DNS server addresses” và gõ vào 2 phần: “Preferred DNS server” và “Alternate DNS server” các địa chỉ sau: DNS1: 208.67.222.222 DNS2: ...

www.webdesign.org

My Code: detail here http://www.webdesign.org/html-and-css/tutorials/spanable-content-box-slicing-coding.12847.html

Any function in JavaScript can be used to create custom object classes

Any function in JavaScript can be used to create custom object classes function myobject() { this.containedValue = 0; this.othercontainedValue = 0; this.anothercontainedValue = 0; } var mything = new myobject(); And there you go, mything is now an instance of class myobject . It will have the following properties, all of which will be 0: mything.containedValue mything.othercontainedValue mything.anothercontainedValue tutorials/javascript/objects

The Navigator Object

The Navigator Object script type="text/javascript"> var browser=navigator.appName; var b_version=navigator.appVersion; var version=parseFloat(b_version); document.write("Browser name: "+ browser); document.write(" "); document.write("Browser version: "+ version); /script> script type="text/javascript"> function detectBrowser() { var browser=navigator.appName; var b_version=navigator.appVersion; var version=parseFloat(b_version); if ((browser=="Netscape"||browser=="Microsoft Internet Explorer") && (version>=4)) { alert("Your browser is good enough!"); } else { alert("It's time to upgrade your browser!"); } } /script>

Google Data APIs Samples

Google Data APIs Samples http://code.google.com/apis/ajax/playground/#expand_mode http://code.google.com/apis/gdata/samples.html#JSON http://code.google.com/apis/base/samples/javascript/js_query_generator/ http://code.google.com/apis/gdata/samples/blogger_sample.html alt Requests results in an alternative format Values: atom, rss, json, json-in-script Default: atom Example: ...&alt=rss callback Causes the specified JavaScript function name to be executed when the data from Google Base is loaded Default: None Notes: Only used when alt=json-in-script Example: ...&alt=json-in-script&callback=yourProcessResultsFunc orderby Define the ranking order for sorting queries Values: relevancy, modification_time, name(type):value, [] Default: relevancy Notes: The Ranking Language reference explains what you can do with this language and defines the language syntax. Example: ...&orderby=price(float USD) crowdby Limit repetitive results by placing a cap on similar items Values: attrib...