程序源码
var floatAd = {};
floatAd.getScrollTop = function(node) {
var doc = ノード ?ノード.ownerDocument : ドキュメント;
戻り doc.documentElement.scrollTop || doc.body.scrollTop;
};
floatAd.getScrollLeft = function(node) {
var doc = ノード ?ノード.ownerDocument : ドキュメント;
return doc.documentElement.scrollLeft || doc.body.scrollLeft;
};
floatAd.getBrowser = function() {
var d = document.documentElement;
return {
width: window.innerWidth || (d && d.clientWidth) || document.body.clientWidth、
高さ: window.innerHeight || (d && d.clientHeight) || document.body.clientHeight
}
};
floatAd.extend = function(destination, source) {
for(source の var プロパティ) {
destination[property] = source[property];
}
戻り先;
};
/* 默认プロパティ扩展 */
floatAd.setOptions = function(options) {
this.options = {
delay: 20, // 调整速度
fadeTime: 1 // 自動消滅時間
};
return this.extend(this.options, options || {});
};
/* 类初化 */
floatAd.init = function(id, options) {
var _this = this;
this.extend(this, this.setOptions(options));
this.control = document.getElementById(id);
var _callback = function() { // フェードイン完了後の回调関数
_this.timer = window.setInterval(function() { _this.scroll() }, _this.lay); // 滚アニメーション定位
window.setTimeout(function() { _this.fadeOut() }, _this.fadeTime * 1000); // 固定時間内に消失
}
this.fadeIn(_callback);
window.onresize = function() { _this.setCenter(); }
};
/* 定時刻滚動 */
floatAd.scroll = function() {
this.start = parseInt(this.control.style.top, 10);
this.end = parseInt(this.getScrollTop() this.getBrowser().height - this.control.clientHeight, 10);
if(this.start != this.end) {
this.amount = Math.ceil(Math.abs(this.end - this.start) / 15); /* 递减公式(this.start無制限增大,整分子無制限减小,整个值就無制限趋近次0) */
this.control.style.top = parseInt(this.control.style.top, 10) ((this.end }
};
/* 目标居中并处在最底部 */
floatAd.setCenter = function() {
this.top = this.getScrollTop() floatAd.getBrowser().height;
this.left = (this.getScrollLeft() floatAd.getBrowser().width - this.control.clientWidth) / 2;
this.control.style.top = this.top 'px';
this.control.style.left = this.left 'px';
};
/* fadeIn */
floatAd.fadeIn = function(callback) {
var _this = this, _top = 0;
this.control.style.display = 'ブロック'; // *要提前显示.不然無法取得clientWidth
this.setCenter();
var _timer = window.setInterval(function() {
_this.control.style.top = _this.getScrollTop() _this.getBrowser().height - ( _top) 'px';
if( _top >= _this.control.clientHeight) {
window.clearInterval(_timer)
callback && callback();
}, 2);
};
/* fadeOut */
floatAd.fadeOut = function() {
var _this = this, _num = 0, _top = _this.control.clientHeight;
window.clearTimeout(this.timer);
var _timer = window.setInterval(function() {
if(_top window.clearInterval(_timer);
_this.control.style.display = 'none' ;
} else {
_this.getScrollTop() _this.getBrowser().height - (--_top) 'px'
}
}; );
this.control.style.top = (parseInt(this.control.style.top, 10) 100) 'px';
};
var newAd = '開始';
document.getElementById('show').onclick = function() {
if(newAd == 'start') {
newAd = floatAd.init('ad', { fadeTime: 10 }) ;
}
}
整个广告运行具有四步動作。
1. 初期化時間は页面最底部にあります。
2. 自底昇昇。まで全体广告漂浮出来
3. 启動检测.滚動時保持广告開始终在页面中最底部。
4. 自動的に設定された間隔に到達します。
全体的に最も重要なことは、制御广告距離文档(非窗口)の最部分の距離.(scrollTop browser.clientHeight).ここでは、この几の代価を提供しています。
获取scrollTop、scrollLeft
注意Chrome と Safari は標準 doc モードの下で使用される根本文も document.documentElement ではなく document.body です
floatAd.getScrollTop = function(node) {
var doc = node ? node.ownerDocument : document;
return doc.documentElement.scrollTop || doc.body.scrollTop;
} ;
floatAd.getScrollLeft = function(node) {
var doc = node ? node.ownerDocument : document;
return doc.documentElement.scrollLeft || doc.body.scrollLeft;
};
Get the width and height of the visual window
floatAd.getBrowser = function() {
var d = document.documentElement;
return {
width: window.innerWidth || (d && d.clientWidth) || document.body.clientWidth ,
height: window.innerHeight || (d && d.clientHeight) || document.body.clientHeight
}
};
Code idea flow
Initialization (init) -----> Set center and hide the bottom (setCenter) -----> FadeIn (fadeIn) -----> FadeIn is completed. Call the callback function _callback ---- ->
Start the countdown to fade time (setTimeout(fadeOut, time)), and bind the real-time detection function (scroll) -----> Hide ads when the custom time is reached (fadeOut)
Instructions for use
Instantiate the function. Pass in the ad container ID. Set the default attributes.
The default attributes are:
delay: 20, // Adjustment rate
fadeTime: 1 // Automatic disappearance time (s)
var newAd = 'start';
document.getElementById ('show').onclick = function() {
if(newAd == 'start') {
newAd = floatAd.init('ad', { fadeTime: 10 });
}
}
This is for convenience of demonstration. So the advertisement is initialized when the button is clicked. The advertisement can also be loaded during window.onload.
Demo download address is displayed in the center floating ad code

JavaScript文字列置換法とFAQの詳細な説明 この記事では、javaScriptの文字列文字を置き換える2つの方法について説明します:内部JavaScriptコードとWebページの内部HTML。 JavaScriptコード内の文字列を交換します 最も直接的な方法は、置換()メソッドを使用することです。 str = str.replace( "find"、 "置換"); この方法は、最初の一致のみを置き換えます。すべての一致を置き換えるには、正規表現を使用して、グローバルフラグGを追加します。 str = str.replace(/fi

それで、あなたはここで、Ajaxと呼ばれるこのことについてすべてを学ぶ準備ができています。しかし、それは正確には何ですか? Ajaxという用語は、動的でインタラクティブなWebコンテンツを作成するために使用されるテクノロジーのゆるいグループ化を指します。 Ajaxという用語は、もともとJesse Jによって造られました

記事では、JavaScriptライブラリの作成、公開、および維持について説明し、計画、開発、テスト、ドキュメント、およびプロモーション戦略に焦点を当てています。

この記事では、ブラウザでJavaScriptのパフォーマンスを最適化するための戦略について説明し、実行時間の短縮、ページの負荷速度への影響を最小限に抑えることに焦点を当てています。

マトリックスの映画効果をあなたのページにもたらしましょう!これは、有名な映画「The Matrix」に基づいたクールなJQueryプラグインです。プラグインは、映画の古典的な緑色のキャラクター効果をシミュレートし、画像を選択するだけで、プラグインはそれを数値文字で満たされたマトリックススタイルの画像に変換します。来て、それを試してみてください、それはとても面白いです! それがどのように機能するか プラグインは画像をキャンバスにロードし、ピクセルと色の値を読み取ります。 data = ctx.getimagedata(x、y、settings.greasize、settings.greasize).data プラグインは、写真の長方形の領域を巧みに読み取り、jQueryを使用して各領域の平均色を計算します。次に、使用します

この記事では、ブラウザ開発者ツールを使用した効果的なJavaScriptデバッグについて説明し、ブレークポイントの設定、コンソールの使用、パフォーマンスの分析に焦点を当てています。

この記事では、jQueryライブラリを使用してシンプルな画像カルーセルを作成するように導きます。 jQuery上に構築されたBXSLiderライブラリを使用し、カルーセルをセットアップするために多くの構成オプションを提供します。 今日、絵のカルーセルはウェブサイトで必須の機能になっています - 1つの写真は千の言葉よりも優れています! 画像カルーセルを使用することを決定した後、次の質問はそれを作成する方法です。まず、高品質の高解像度の写真を収集する必要があります。 次に、HTMLとJavaScriptコードを使用して画像カルーセルを作成する必要があります。ウェブ上には、さまざまな方法でカルーセルを作成するのに役立つ多くのライブラリがあります。オープンソースBXSLiderライブラリを使用します。 BXSLiderライブラリはレスポンシブデザインをサポートしているため、このライブラリで構築されたカルーセルは任意のものに適合させることができます

データセットは、APIモデルとさまざまなビジネスプロセスの構築に非常に不可欠です。これが、CSVのインポートとエクスポートが頻繁に必要な機能である理由です。このチュートリアルでは、Angular内でCSVファイルをダウンロードおよびインポートする方法を学びます


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

SublimeText3 英語版
推奨: Win バージョン、コードプロンプトをサポート!

SecLists
SecLists は、セキュリティ テスターの究極の相棒です。これは、セキュリティ評価中に頻繁に使用されるさまざまな種類のリストを 1 か所にまとめたものです。 SecLists は、セキュリティ テスターが必要とする可能性のあるすべてのリストを便利に提供することで、セキュリティ テストをより効率的かつ生産的にするのに役立ちます。リストの種類には、ユーザー名、パスワード、URL、ファジング ペイロード、機密データ パターン、Web シェルなどが含まれます。テスターはこのリポジトリを新しいテスト マシンにプルするだけで、必要なあらゆる種類のリストにアクセスできるようになります。

Dreamweaver Mac版
ビジュアル Web 開発ツール

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

SublimeText3 Linux 新バージョン
SublimeText3 Linux 最新バージョン

ホットトピック



