検索
ホームページウェブフロントエンドjsチュートリアルjquery で iframe_jquery を操作するいくつかの方法のまとめ

iframe は複合ドキュメントでよく使用されます。jquery を使用して iframe を操作すると、効率が大幅に向上します。

DOM メソッド:
親ウィンドウ操作 IFRAME: window.frames["iframeSon"].document
IFRAME 操作親ウィンドウ: window.parent.document

jquery メソッド:
親ウィンドウの IFRAME 内のすべての入力ボックスを選択します: $(window.frames["iframeSon"].document).find(":text"); 🎜>IFRAME の親ウィンドウですべての入力ボックスを選択します: $(window.parent.document).find(":text");

iframe HTML:

1. 親ウィンドウの IFRAME 内のすべてのラジオ ボタンを選択します
$(window.frames["iframe1"].document).find("input[@type=' radio' ]").attr("チェック済み","true");

2. IFRAME の親ウィンドウ内のすべてのラジオ ボタンを選択します
$(window.parent.document).find("input[@type='radio']") .attr ("チェック済み","true");

iframe フレーム:

コードをコピー コードは次のとおりです。
="../js/jquery-1.2.6.js" type="text/ecmascript "> ;



收集利用Jquery取得iframe中元素的几种方法 :

$(document.getElementById('iframeId').contentWindow.document.body).htm() 
$(document.getElementById('iframeId').contentWindow.document.body).htm() 

显示iframe中body元素的内容。

$("#testId", document.frames("iframename").document).html(); 
$("#testId", document.frames("iframename").document).html(); 

根据iframename取得其中ID为"testId"元素

$(window.frames["iframeName"].document).find("#testId").html() 
$(window.frames["iframeName"].document).find("#testId").html() 

作用同上
收集网上的一些示例:

用jQuery在IFRAME里取得父窗口的某个元素的值
只好用DOM方法与jquery方法结合的方式实现了

1.在父窗口中操作 选中IFRAME中的所有单选钮
$(window.frames["iframe1"].document).find("input[@type='radio']").attr("checked","true");

2.在IFRAME中操作 选中父窗口中的所有单选钮
$(window.parent.document).find("input[@type='radio']").attr("checked","true");

iframe框架的:

IE7中测试通过


使用jquery操作iframe

1、内容里有两个ifame

leftiframe中jQuery改变mainiframe的src代码:
$(">

2、如果内容里面有一个ID为mainiframe的ifame

$("#mainiframe").contents().find("someID").html() html or $("#mainiframe").contains().find("someID").text() value

3. Select all radio buttons in the IFRAME in the parent window
$(window.frames["iframe1"].document).find("input[@type=' radio']").attr("checked","true");

Then choosing the id is naturally to still use the find method
$(window.frames["iframe1"].document).find("#id")

4. As shown above
jQuery in leftiframe operates the content of mainiframe and the content of someID
$("#mainframe",parent.document.body).contents(). find("someID").html() or $("#mainframe",parent.document.body).contents().find("someID").val()


Use JavaScript to manipulate iframes

References between frames

All frames in a page are provided as attributes of the window object in the form of a collection. For example: window.frames represents the collection of all frames in the page, which is similar to form objects, link objects, picture objects, etc. The difference is that these collections are properties of the document. Therefore, to reference a subframe, you can use the following syntax:

window.frames["frameName"];

window.frames.frameName

window.frames[index]

Among them, the word window can also be replaced or omitted with self. Assuming that frameName is the first frame in the page, the following writing methods are equivalent:

self.frames["frameName"]

self.frames[0]

frames[0]

frameName

Each frame corresponds to an HTML page, so this frame is also an independent browser window. It has all the properties of a window. The so-called reference to the frame is also a reference to the window object. With this window object, you can easily operate the pages in it, such as using the window.document object to write data to the page, using the window.location property to change the page in the frame, etc.

The following introduces the mutual references between different levels of frameworks:

1. Reference from parent frame to child frame

Knowing the above principles, it is very easy to reference the child frame from the parent frame, that is:

window.frames["frameName"];

This references the subframe named frameName within the page. If you want to reference a subframe within a subframe, according to the nature of the referenced frame, which is actually the window object, you can implement it like this:

window.frames["frameName"].frames["frameName2"];

In this way, the second-level sub-frame is referenced, and by analogy, multi-layer framework references can be achieved.

2. Reference from child frame to parent frame

Each window object has a parent attribute, representing its parent frame. If the frame is already a top-level frame, window.parent also represents the frame itself.

3. References between sibling frameworks

If two frames are sub-frames of the same frame, they are called sibling frames and can reference each other through the parent frame. For example, a page includes 2 sub-frames:

You can use the following statement in frame1 to reference frame2:

self.parent.frames["frame2"];

4. Mutual references between frameworks at different levels

The hierarchy of frames is for top-level frames. When the levels are different, as long as you know the level you are at and the level and name of the other frame, you can easily access each other by using the properties of the window object referenced by the frame, for example:

self.parent.frames["childName"].frames["targetFrameName"];

5. Reference to the top-level frame

Similar to the parent attribute, the window object also has a top attribute. It represents a reference to the top-level frame, which can be used to determine whether a frame itself is a top-level frame, for example:

//Determine whether this frame is a top-level frame

if(self==top){

//dosomething

}

声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
JavaScript in Action:実際の例とプロジェクトJavaScript in Action:実際の例とプロジェクトApr 19, 2025 am 12:13 AM

現実世界でのJavaScriptのアプリケーションには、フロントエンドとバックエンドの開発が含まれます。 1)DOM操作とイベント処理を含むTODOリストアプリケーションを構築して、フロントエンドアプリケーションを表示します。 2)node.jsを介してRestfulapiを構築し、バックエンドアプリケーションをデモンストレーションします。

JavaScriptとWeb:コア機能とユースケースJavaScriptとWeb:コア機能とユースケースApr 18, 2025 am 12:19 AM

Web開発におけるJavaScriptの主な用途には、クライアントの相互作用、フォーム検証、非同期通信が含まれます。 1)DOM操作による動的なコンテンツの更新とユーザーインタラクション。 2)ユーザーエクスペリエンスを改善するためにデータを提出する前に、クライアントの検証が実行されます。 3)サーバーとのリフレッシュレス通信は、AJAXテクノロジーを通じて達成されます。

JavaScriptエンジンの理解:実装の詳細JavaScriptエンジンの理解:実装の詳細Apr 17, 2025 am 12:05 AM

JavaScriptエンジンが内部的にどのように機能するかを理解することは、開発者にとってより効率的なコードの作成とパフォーマンスのボトルネックと最適化戦略の理解に役立つためです。 1)エンジンのワークフローには、3つの段階が含まれます。解析、コンパイル、実行。 2)実行プロセス中、エンジンはインラインキャッシュや非表示クラスなどの動的最適化を実行します。 3)ベストプラクティスには、グローバル変数の避け、ループの最適化、constとletsの使用、閉鎖の過度の使用の回避が含まれます。

Python vs. JavaScript:学習曲線と使いやすさPython vs. JavaScript:学習曲線と使いやすさApr 16, 2025 am 12:12 AM

Pythonは、スムーズな学習曲線と簡潔な構文を備えた初心者により適しています。 JavaScriptは、急な学習曲線と柔軟な構文を備えたフロントエンド開発に適しています。 1。Python構文は直感的で、データサイエンスやバックエンド開発に適しています。 2。JavaScriptは柔軟で、フロントエンドおよびサーバー側のプログラミングで広く使用されています。

Python vs. JavaScript:コミュニティ、ライブラリ、リソースPython vs. JavaScript:コミュニティ、ライブラリ、リソースApr 15, 2025 am 12:16 AM

PythonとJavaScriptには、コミュニティ、ライブラリ、リソースの観点から、独自の利点と短所があります。 1)Pythonコミュニティはフレンドリーで初心者に適していますが、フロントエンドの開発リソースはJavaScriptほど豊富ではありません。 2)Pythonはデータサイエンスおよび機械学習ライブラリで強力ですが、JavaScriptはフロントエンド開発ライブラリとフレームワークで優れています。 3)どちらも豊富な学習リソースを持っていますが、Pythonは公式文書から始めるのに適していますが、JavaScriptはMDNWebDocsにより優れています。選択は、プロジェクトのニーズと個人的な関心に基づいている必要があります。

C/CからJavaScriptへ:すべてがどのように機能するかC/CからJavaScriptへ:すべてがどのように機能するかApr 14, 2025 am 12:05 AM

C/CからJavaScriptへのシフトには、動的なタイピング、ゴミ収集、非同期プログラミングへの適応が必要です。 1)C/Cは、手動メモリ管理を必要とする静的に型付けられた言語であり、JavaScriptは動的に型付けされ、ごみ収集が自動的に処理されます。 2)C/Cはマシンコードにコンパイルする必要がありますが、JavaScriptは解釈言語です。 3)JavaScriptは、閉鎖、プロトタイプチェーン、約束などの概念を導入します。これにより、柔軟性と非同期プログラミング機能が向上します。

JavaScriptエンジン:実装の比較JavaScriptエンジン:実装の比較Apr 13, 2025 am 12:05 AM

さまざまなJavaScriptエンジンは、各エンジンの実装原則と最適化戦略が異なるため、JavaScriptコードを解析および実行するときに異なる効果をもたらします。 1。語彙分析:ソースコードを語彙ユニットに変換します。 2。文法分析:抽象的な構文ツリーを生成します。 3。最適化とコンパイル:JITコンパイラを介してマシンコードを生成します。 4。実行:マシンコードを実行します。 V8エンジンはインスタントコンピレーションと非表示クラスを通じて最適化され、Spidermonkeyはタイプ推論システムを使用して、同じコードで異なるパフォーマンスパフォーマンスをもたらします。

ブラウザを超えて:現実世界のJavaScriptブラウザを超えて:現実世界のJavaScriptApr 12, 2025 am 12:06 AM

現実世界におけるJavaScriptのアプリケーションには、サーバー側のプログラミング、モバイルアプリケーション開発、モノのインターネット制御が含まれます。 2。モバイルアプリケーションの開発は、ReactNativeを通じて実行され、クロスプラットフォームの展開をサポートします。 3.ハードウェアの相互作用に適したJohnny-Fiveライブラリを介したIoTデバイス制御に使用されます。

See all articles

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

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

AI Clothes Remover

AI Clothes Remover

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

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

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

ホットツール

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

PhpStorm Mac バージョン

PhpStorm Mac バージョン

最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SecLists

SecLists

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

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい