modal-dialog 相关问题

指用于向用户显示重要信息的图形对话框。这些对话框显示在所有其他内容之上,阻止应用程序流,直到收到用户输入。

页面上的 CSS JS 和 HTML Modal 使用按钮和链接触发窗口

我希望能够使用链接(而不是按钮)来触发模式窗口。 事实上,我想在同一代码库中使用其中之一...... 按钮可以工作,但链接:“打开...

回答 1 投票 0

Bootstrap 5 - 模态未显示

我试图在使用以下代码单击图像时打开模式: 当使用此代码单击图像时,我尝试打开模式: <!-- Button trigger modal --> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal"> Launch demo modal </button> <!-- Modal --> <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Modal title</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> ... </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> </div> </div> 这是来自Bootstrap Modal Doc的原始代码 但还没开始工作,我点击按钮却什么也没发生 可能您错过了一些引导程序依赖项。 这是完整的代码演示: <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous"> </head> <body> <!-- Bootstrap Bundle with Popper --> <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-gtEjrD/SeCtmISkJkNUaaKMoLD0//ElJ19smozuHV6z3Iehds+3Ulb9Bn9Plx0x4" crossorigin="anonymous"></script> <!-- Dialog demo --> <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModalLive"> Launch demo modal </button> <div class="modal fade" id="exampleModalLive" tabindex="-1" aria-labelledby="exampleModalLiveLabel" style="display: none;" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLiveLabel">Modal title</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> <p>Woohoo, you're reading this text in a modal!</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> <button type="button" class="btn btn-primary">Save changes</button> </div> </div> </div> </div> </body> </html>

回答 1 投票 0

如何使用javascript弹出/打开引导模式?

我需要使用 JavaScript 显示引导模式。我尝试了下面提到的从互联网上获得的代码,但它不起作用。我也看到了 bootstrap.com 网站,但没有找到好的答案。我

回答 1 投票 0

我可以隐藏 HTML/CSS/JS 模式,但显示时它位置不正确或具有背景颜色或边框

我假设我的 JS 和 HTML 是正确的。我把完整的代码放了进去,没有那么长,所以整个问题都可以看到。我复制了几个网站的CSS策略,但没有效果。我确实尝试过信誉良好的网站,...

回答 3 投票 0

JQuery:多个 div 在表中的特定 ID 上以单个模式显示

我创建了多个段落,以通过表格内的按钮在特定类上以单一模式显示。我在 json 附加中创建了类“dugme_${kurs.id}”,效果很好。每个按钮都...

回答 2 投票 0

当我单击关闭按钮时,模态关闭功能不起作用

const [modalOpen, setModalOpen] = useState(false); const openModal= ()=>{ setModalOpen(真); } const closeModal = () => { setModalOpen(假); }; ...

回答 1 投票 0

Bootstrap 模式选项已存在后进行更改

我正在使用 Bootstrap Modal。我声明它,我调用它,我展示它......一切似乎都很好。 但是,如果我有一个已经存在的模式,之前显示的“键盘”属性为 false,并且我想要......

回答 9 投票 0

React - 打开/关闭模式并根据卡片特定数据进行填充

我设置了一些卡片,其中每张卡片都包含特定数据(职位编号、职位等),并且我尝试添加一个弹出模式,可用于查看有关该职位的更多详细信息。如果您点击“查看

回答 1 投票 0

PrimeNG 将数据从动态对话框发送到其父组件

我有一个功能齐全的 PrimeNG 对话正在运行。我使用 DynamicDialogService.open 将数据传递给它,但是我们如何将数据发送回父级? 发回数据不会出现在文档中...

回答 1 投票 0

如何在同步融合调度程序对话框中仅拖动标题

net core C# 同步融合调度程序。 我使调度程序的对话框可拖动 函数 OnPopupOpen(args) { var DragElement = document.getElementById('schedule_dialog_wrapper'); ...

回答 1 投票 0

在模式窗口中打开 iframe,其中 iframe src=variable Google Sheets

我可以在模式窗口中打开一个 iframe .embed-container { 位置:相对;底部填充:54.25%;高度:0;溢出:隐藏...</desc> <question vote="0"> <p>我可以在模态窗口中打开 iframe </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;style&gt;.embed-container { position: relative; padding-bottom: 54.25%; height: 0; overflow: hidden; min-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }&lt;/style&gt;&lt;div class=&#39;embed-container&#39;&gt;&lt;iframe src=&#39;https://www.soscisurvey.de/tools/view-chars.php&#39; style=&#39;border:0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>iframe <pre><code>sar</code></pre> 链接是硬编码的。 但我需要将 iframe 链接添加为气体函数的变量。</p> <p>我有</p> <p>煤气</p> <pre><code>function openPopup() { var html = HtmlService.createHtmlOutputFromFile(&#39;index&#39;); html.mylink = &#39;https://www.soscisurvey.de/tools/view-chars.php&#39; html.setHeight(2000) html.setWidth(5000) SpreadsheetApp.getUi() .showModalDialog(html.evaluate().setSandboxMode(HtmlService.SandboxMode.IFRAME), &#39;Dialog title&#39;); } </code></pre> <p>HTML</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;style&gt;.embed-container { position: relative; padding-bottom: 54.25%; height: 0; overflow: hidden; min-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }&lt;/style&gt;&lt;div class=&#39;embed-container&#39;&gt;&lt;iframe src=&lt;?= mylink ?&gt; style=&#39;border:0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>我收到错误。</p> <pre><code>Error Exception: Malformed HTML content: &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;style&gt;.embed-container { position: relative; padding-bottom: 54.25%; height: 0; overflow: hidden; min-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }&lt;/style&gt;&lt;div class=&#39;embed-container&#39;&gt;&lt;iframe src=&lt;?= mylink ?&gt; style=&#39;border:0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt;. </code></pre> <p>显然它不喜欢<pre><code>src=&lt;?= mylink ?&gt;</code></pre></p> <p>如何做到这一点?</p> <p>谢谢</p> </question> <answer tick="false" vote="0"> <p>试试这个方法:</p> <p>html:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;base target=&#34;_top&#34;&gt; &lt;/head&gt; &lt;body&gt; &lt;style&gt;.embed-container { position: relative; padding-bottom: 54.25%; height: 0; overflow: hidden; min-width: 100%; } .embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }&lt;/style&gt; &lt;div class=&#39;embed-container&#39;&gt;&lt;iframe src=&lt;?= mylink ?&gt; style=&#39;border:0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>气体:</p> <pre><code>function openPopup() { var t = HtmlService.createTemplateFromFile(&#39;ah3&#39;); t.mylink = &#34;&#39;https://www.soscisurvey.de/tools/view-chars.php&#39;&#34; let html = t.evaluate(); html.setHeight(2000); html.setWidth(5000); html.setSandboxMode(HtmlService.SandboxMode.IFRAME); SpreadsheetApp.getUi().showModalDialog(html, &#39;Dialog title&#39;); } </code></pre> </answer> </body></html>

回答 0 投票 0

通过模态编辑用户信息

我正在为我和我的朋友开发一个小型的 Interrail Planner。 目前,我正在尝试创建一个模式来编辑/更新旅行者信息。 首先,我把它放在一个单独的文件中。 一个

回答 1 投票 0

Bootstrap 5.3 将打开模式上的背景更改为静态(JavaScript/JQuery)

如何通过 jQuery 或 JavaScript 将开放模式上的背景更改为“静态”? ?我需要防止用户在单击模式上的“提交”按钮后单击关闭模式。我...

回答 1 投票 0

如何让react组件从dom上完全消失,从而保留动画?

App.jsx 从“react”导入 React, { useState }; 从“./components/Modal/Modal”导入模态; 导出默认函数 App() { const [showModal, setShowModal] = useState(fals...

回答 1 投票 0

我可以循环使用 R Shiny showModal 吗?

我知道这里有一些类似的问题,但它们都有几年历史了,而且似乎都指向使用shinyalert包而不是showModal。我的基本问题是我需要允许......

回答 1 投票 0

在 React 中单击关闭按钮后 Boostrap 模式仍然保留

当我单击“创建故事”按钮时,它会显示登录表单,成功登录后,会显示“创建故事表单”组件,但在尝试关闭模式时,它不会...

回答 1 投票 0

锚点和按钮在 React 模式中不可点击

我正在尝试使用 ReactDOM.createPortal 来拥有一个可以从 React 应用程序中的任何位置打开的全局模式。模式将打开并正确显示。问题是 和 元素...

回答 0 投票 0

闪亮模态未按预期在服务器中显示

所以我目前正在编写一个测试闪亮应用程序游戏来测试我为主游戏应用程序编写的辅助函数。 在主应用程序中,提款金额和其他一些参数将由...

回答 0 投票 0

使用 selenium 和 python 处理模态

<div id="pageHeader" class="mediumActivityList hasBanner hasMainNav hasSubNav"><div id="rwdNavBlock"><div id="rwdNavLogo" class="golfLogo"></div><div id="rwdNav" role="navigation"><ul><li aria-haspopup="true" class="topnav_item"><a href="#" class=""><span class="topnav_item">Tee Times</span></a><ul style=""><li aria-haspopup="false" class=""><a href="Member_select" class=".ftSlotConflitInit"><span class="">Make, Change, or View Tee Times</span></a></li><li aria-haspopup="false" class=""><a href="Member_sheet?index=0" class=".ftSlotConflitInit"><span class="">Today's Tee Sheet</span></a></li><li aria-haspopup="false" class=""><a href="Member_teelist" class=".ftSlotConflitInit"><span class="">My Tee Times / Calendar</span></a></li><li aria-haspopup="false" class=""><a href="Member_teelist_list" class=".ftSlotConflitInit"><span class="">My Tee Times / List</span></a></li><li aria-haspopup="false" class=" lastItem"><a href="Member_joinMe_list" class=".ftSlotConflitInit"><span class="">Looking for Players to Join</span></a></li></ul></li> <li aria-haspopup="false" class="topnav_item"><a href="Member_events" class=".ftSlotConflitInit"><span class="topnav_item">Events</span></a></li> <li aria-haspopup="true" class="topnav_item"><a href="#" class=""><span class="topnav_item">Lessons</span></a><ul style=""><li aria-haspopup="false" class=""><a href="Member_lesson" class=".ftSlotConflitInit"><span class="">Individual Lessons</span></a></li><li aria-haspopup="false" class=""><a href="Member_lesson?group=yes" class=".ftSlotConflitInit"><span class="">Group Lessons</span></a></li><li aria-haspopup="false" class=""><a href="Member_lesson?all_search" class=".ftSlotConflitInit"><span class="">All Open Pro Lessons</span></a></li><li aria-haspopup="false" class=""><a href="Member_lesson?bio=yes" class=".ftSlotConflitInit"><span class="">View Pros' Bios</span></a></li><li aria-haspopup="false" class=" lastItem"><a href="Member_teelist_list?mode=lesson" class=".ftSlotConflitInit"><span class="">My Scheduled Lessons</span></a></li></ul></li> <li aria-haspopup="true" class="topnav_item"><a href="#" class=""><span class="topnav_item">Handicaps</span></a><ul style=""><li aria-haspopup="false" class=" lastItem"><a href="Member_handicaps?todo=view" class=".ftSlotConflitInit"><span class="">View Handicaps and Scores</span></a></li></ul></li> <li aria-haspopup="true" class="topnav_item"><a href="#" class=""><span class="topnav_item">Search</span></a><ul style=""><li aria-haspopup="false" class=""><a href="Member_searchmem" class=".ftSlotConflitInit"><span class="">Other Members' Tee Times</span></a></li><li aria-haspopup="false" class=""><a href="Member_searchpast?subtee=cal" class=".ftSlotConflitInit"><span class="">Your Past Tee Times - This Calendar Year</span></a></li><li aria-haspopup="false" class=""><a href="Member_searchpast?subtee=year" class=".ftSlotConflitInit"><span class="">Your Past Tee Times - Past 12 Months</span></a></li><li aria-haspopup="false" class=" lastItem"><a href="Member_searchpast?subtee=forever" class=".ftSlotConflitInit"><span class="">Your Past Tee Times - Since Inception</span></a></li></ul></li> <li aria-haspopup="true" class="topnav_item"><a href="#" class=""><span class="topnav_item">Email</span></a><ul style=""><li aria-haspopup="false" class=""><a href="Member_email" class=".ftSlotConflitInit"><span class="">Send Email</span></a></li><li aria-haspopup="false" class=" lastItem"><a href="Member_email?manage_distribution_lists" class=".ftSlotConflitInit"><span class="">Manage Distribution Lists</span></a></li></ul></li> <li aria-haspopup="false" class="topnav_item"><a href="Member_partner" class=".ftSlotConflitInit"><span class="topnav_item">Partners</span></a></li> <li aria-haspopup="false" class="topnav_right_item profileNavItem"><a href="Member_services" class=".ftSlotConflitInit"><span class="topnav_right_item profileNavItem">Settings</span></a></li> <li aria-haspopup="false" class="topnav_right_item helpNavItem"><a href="Member_help_rwd" class=".ftSlotConflitInit"><span class="topnav_right_item helpNavItem">Help</span></a></li> <li aria-haspopup="false" class="topnav_right_item lastItem"><a href="Logout?u=311&amp;ftc=0&amp;ext=0&amp;cl=GJONAS74912" class=".ftSlotConflitInit"><span class="topnav_right_item">Exit</span></a></li></ul></div><div id="rwdNav2" role="navigation"><a id="rwdNavButton" href="#rwdNav2" title="Menu" class="ftB-36-White ftB-36-Menu"><span></span><span>Menu</span></a><ul class="ui-accordion ui-widget ui-helper-reset" role="tablist"><li aria-haspopup="true" class="topnav_item "><a href="#" class="ui-accordion-header ui-state-default ui-corner-all ui-accordion-icons" role="tab" id="ui-id-1" aria-controls="ui-id-2" aria-selected="false" aria-expanded="false" tabindex="0"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span><span class="topnav_item">Tee Times</span></a><ul class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" id="ui-id-2" aria-labelledby="ui-id-1" role="tabpanel" aria-hidden="true" style="display: none;"><li aria-haspopup="false" class=""><a href="Member_select" class=".ftSlotConflitInit"><span class="">Make, Change, or View Tee Times</span></a></li><li aria-haspopup="false" class=""><a href="Member_sheet?index=0" class=".ftSlotConflitInit"><span class="">Today's Tee Sheet</span></a></li><li aria-haspopup="false" class=""><a href="Member_teelist" class=".ftSlotConflitInit"><span class="">My Tee Times / Calendar</span></a></li><li aria-haspopup="false" class=""><a href="Member_teelist_list" class=".ftSlotConflitInit"><span class="">My Tee Times / List</span></a></li><li aria-haspopup="false" class=" lastItem"><a href="Member_joinMe_list" class=".ftSlotConflitInit"><span class="">Looking for Players to Join</span></a></li></ul></li> <li aria-haspopup="false" class="topnav_item"><a href="Member_events" class="ui-accordion-header ui-state-default ui-corner-all ui-accordion-icons noChildren .ftSlotConflitInit" role="tab" id="ui-id-3" aria-selected="false" aria-expanded="false" tabindex="-1"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span><span class="topnav_item">Events</span></a></li> <li aria-haspopup="true" class="topnav_item "><a href="#" class="ui-accordion-header ui-state-default ui-corner-all ui-accordion-icons" role="tab" id="ui-id-4" aria-controls="ui-id-5" aria-selected="false" aria-expanded="false" tabindex="-1"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span><span class="topnav_item">Lessons</span></a><ul class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" id="ui-id-5" aria-labelledby="ui-id-4" role="tabpanel" aria-hidden="true" style="display: none;"><li aria-haspopup="false" class=""><a href="Member_lesson" class=".ftSlotConflitInit"><span class="">Individual Lessons</span></a></li><li aria-haspopup="false" class=""><a href="Member_lesson?group=yes" class=".ftSlotConflitInit"><span class="">Group Lessons</span></a></li><li aria-haspopup="false" class=""><a href="Member_lesson?all_search" class=".ftSlotConflitInit"><span class="">All Open Pro Lessons</span></a></li><li aria-haspopup="false" class=""><a href="Member_lesson?bio=yes" class=".ftSlotConflitInit"><span class="">View Pros' Bios</span></a></li><li aria-haspopup="false" class=" lastItem"><a href="Member_teelist_list?mode=lesson" class=".ftSlotConflitInit"><span class="">My Scheduled Lessons</span></a></li></ul></li> <li aria-haspopup="true" class="topnav_item "><a href="#" class="ui-accordion-header ui-state-default ui-corner-all ui-accordion-icons" role="tab" id="ui-id-6" aria-controls="ui-id-7" aria-selected="false" aria-expanded="false" tabindex="-1"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span><span class="topnav_item">Handicaps</span></a><ul class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" id="ui-id-7" aria-labelledby="ui-id-6" role="tabpanel" aria-hidden="true" style="display: none;"><li aria-haspopup="false" class=" lastItem"><a href="Member_handicaps?todo=view" class=".ftSlotConflitInit"><span class="">View Handicaps and Scores</span></a></li></ul></li> <li aria-haspopup="true" class="topnav_item "><a href="#" class="ui-accordion-header ui-state-default ui-corner-all ui-accordion-icons" role="tab" id="ui-id-8" aria-controls="ui-id-9" aria-selected="false" aria-expanded="false" tabindex="-1"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span><span class="topnav_item">Search</span></a><ul class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" id="ui-id-9" aria-labelledby="ui-id-8" role="tabpanel" aria-hidden="true" style="display: none;"><li aria-haspopup="false" class=""><a span></a></li> <li aria-haspopup="false" class="topnav_right_item helpNavItem"><a href="Member_help_rwd" class="ui-accordion-header ui-state-default ui-corner-all ui-accordion-icons noChildren .ftSlotConflitInit" role="tab" id="ui-id-14" aria-selected="false" aria-expanded="false" tabindex="-1"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span><span class="topnav_right_item helpNavItem">Help</span></a></li> <li aria-haspopup="false" class="topnav_right_item lastItem"><a href="Logout?u=311&amp;ftc=0&amp;ext=0&amp;cl=GJONAS74912" class="ui-accordion-header ui-state-default ui-corner-all ui-accordion-icons noChildren .ftSlotConflitInit" role="tab" id="ui-id-15" aria-selected="false" aria-expanded="false" tabindex="-1"><span class="ui-accordion-header-icon ui-icon ui-icon-triangle-1-e"></span><span class="topnav_right_item">Exit</span></a></li></ul><a id="rwdHelpButton" href="Member_help_rwd" title="Menu" class="ftB-36-White ftB-36-Help ftB-36-Right helpTopic ft-helpLink .ftSlotConflitInit"><span></span><span>Help</span></a></div></div><div class="banner_container"><div class="rwd_banner"><div class="banner_title"><a id="title" href="Member_announce" class=".ftSlotConflitInit">The Club at Mediterra</a></div><div class="welcome_member"><span>Welcome,</span> <span>Stephen Smith</span></div><div id="weather"><a href="https://wwwa.accuweather.com/forecast.asp?partner=&amp;zipcode=34110" <div class="slot_container" data- </div> <div id="footer"> <div class="modal_list pleaseWait_container"></div> <div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front newpropushbelowmenu ui-dialog-buttons" tabindex="-1" role="dialog" aria-describedby="ui-id-16" aria-labelledby="ui-id-17" style="height: auto; width: 650px; top: 391px; left: 418px; display: block; z-index: 101;"> <div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"> <span id="ui-id-17" class="ui-dialog-title">Notice</span> <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" role="button" title="Close" style="display: none;"> <span class="ui-button-icon-primary ui-icon ui-icon-closethick"> </span> <span class="ui-button-text">Close</span> </button> </div> <div class="modal_list slotPageLoadNotification_container ui-dialog-content ui-widget-content" id="ui-id-16" style="width: auto; min-height: 97px; max-height: 924px; height: auto;"> <div class="sub_instructions"> Sorry, the time you requested is not available. Would you like an alternate time?<br> <br> The next available tee time is: <b>3:23 PM <br><br><br>Select "Continue" to use this alternate time.</b> </div> </div> <div class="pleaseWaitActivityIndicator" style="position: absolute; inset: 0px; display: none;"> </div><div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"> <div class="ui-dialog-buttonset"> <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button"> <span class="ui-button-text">Go Back</span> </button> <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button"> <span class="ui-button-text">Continue</span> </button> </div> </div> </div> <div class="ui-widget-overlay ui-front" style="z-index: 100;"></div></body></html> 我正在尝试访问在某些情况下显示的模式。我已经阅读了我能找到的所有内容,观看了有关该主题的 YouTube 视频,并进行了大量尝试,但没有成功。在我看来,模态内部的元素是不可访问的——我尝试过等待、睡眠等。我也尝试过切换到逻辑。我已附上两个元素的相关 HTML 和 XPATH 地址的副本。请注意,这些元素彼此相邻 - 第二个元素紧随第一个元素。我可以使用 xpath 查找元素访问第一个(/html/body/div[4])(我收到一条键入的消息),但我无法访问第二个([5])** br.find_element(By.XPATH, "/html/body/div[4]") print(thread, "found modal list please wait container") sleep(5) br.find_element(By.XPATH, "/html/body/div[5]") print(thread, "line after modal list please wait container") **使用几乎相同的位置(xpath 地址略有变化)。如果有人能引导我走向正确的方向,我将不胜感激。 感谢您的阅读。 绝对xpath,例如: /html/body/div[4] 和 /html/body/div[5] 具有从根到我们想要识别的元素的完整路径,总是很脆弱,就像从根到元素的属性发生任何变化一样,我们的绝对xpath将变得无效。 解决方案 您可以使用逻辑 xpath,而不是绝对 xpath,如下所示: br.find_element(By.XPATH, "//div[@id='footer']/div[@class='modal_list pleaseWait_container']") print(thread, "found modal list please wait container") sleep(5) br.find_element(By.XPATH, "//div[@id='footer']/div[@class='ui-dialog ui-widget ui-widget-content ui-corner-all ui-front newpropushbelowmenu ui-dialog-buttons']") print(thread, "line after modal list please wait container") 此外,由于元素位于 Modal 内,理想情况下您需要为 presence_of_element_ located() 引入 WebDriverWait 并且您可以使用以下 定位器策略: WebDriverWait(br, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@id='footer']/div[@class='modal_list pleaseWait_container']"))) print(thread, "found modal list please wait container") WebDriverWait(br, 20).until(EC.presence_of_element_located((By.XPATH, "//div[@id='footer']/div[@class='ui-dialog ui-widget ui-widget-content ui-corner-all ui-front newpropushbelowmenu ui-dialog-buttons']"))) print(thread, "line after modal list please wait container") 注意:您必须添加以下导入: from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC

回答 1 投票 0

所有点击事件和链接在模式消失后停止工作?

当我登录我的应用程序并且 SingIn-Modal 组件在成功登录后消失时,我网站上的所有内容都变得不可点击: @click 事件不起作用 链接不起作用 文本不可选择

回答 0 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.