簡體   English   中英

在div中顯示URL的內容

[英]display content of a URL in a div

我打開一個彈出窗口,格式如下:

window.open('http://URL', 'invitationwindow', 'height=250,width=500,scrollbars=yes,resizable=yes,status=yes')

我該如何在同一頁面的div中獲取彈出窗口的內容。 我的意思是,我不想要彈出窗口,但它的內容應該顯示在彈出窗口的同一頁面中。

如何使用Jquery完成? 我知道.append().html()會向div添加內容,但在這種情況下,我會從http://example.com等網址獲取內容。

謝謝!

使用jquery load()

$('#mydiv').load('http://URL');

通常人們會使用<iframe>

使用jquery,使用:

$.get('ajax/test.html', function(data) {
  $('.result').html(data);
  alert('Load was performed.');
});

$('#result').load('ajax/test.html', function() {
  alert('Load was performed.');
});

希望能幫助到你!

顯示特定的<div> setTimeout() 處的內容</div><div id="text_translate"><p>在下面的代碼中,我正在使用setTimeout()對我的后端 node.js 應用程序進行 API 調用,該應用程序每 5 秒調用一次我的 AJAX。 在我的 AJAX 成功中,我根據應至少執行一次的特定條件顯示divContent1和divContent2 。 之后,在每個setTimeout()調用中,只有divContent2應該是可見的。</p><p> <strong>索引.html</strong></p><pre> &lt;script type="text/javascript"&gt; $(document).ready(function(){ $.ajax({ url: "http://localhost:8070/api/route1", type: 'POST', dataType:'json', success: function(res) { //Some Task } }); $("#myButton").click(function(){ const route2 = function() { $.ajax({ url: "http://localhost:8070/api/route2", type: "POST", dataType: "json", data: { var1: val1 }, success: function (res) { // Various tasks if(res.flag){ $("#divContent1").hide(); $("#divContent2").show(); } else{ $("#divContent1").show(); } //Functions that handle div content data }, beforeSend: function() { $("#divContent1").hide(); $("#divContent2").hide(); }, complete: function() { setTimeout(route2,5000); }, }); }; $(function(){ route2(); }) }); }); &lt;/script&gt;</pre><p> setTimeout() 調用整個route2來處理div內容的所有顯示和插入。 但是,要求僅顯示第二次調用的divContent2 。</p><p> 尋找解決方案</p></div>

[英]Display a specific <div> content at setTimeout()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

相關問題 根據 URL 顯示特定的 div 或內容 使用JQuery根據URL的內容顯示div 展示<textarea> &lt;div&gt; 中的內容 顯示DIV中的內容 在div中顯示不同的內容 onClick圖片,顯示div內容 顯示特定的<div> setTimeout() 處的內容</div><div id="text_translate"><p>在下面的代碼中,我正在使用setTimeout()對我的后端 node.js 應用程序進行 API 調用,該應用程序每 5 秒調用一次我的 AJAX。 在我的 AJAX 成功中,我根據應至少執行一次的特定條件顯示divContent1和divContent2 。 之后,在每個setTimeout()調用中,只有divContent2應該是可見的。</p><p> <strong>索引.html</strong></p><pre> &lt;script type="text/javascript"&gt; $(document).ready(function(){ $.ajax({ url: "http://localhost:8070/api/route1", type: 'POST', dataType:'json', success: function(res) { //Some Task } }); $("#myButton").click(function(){ const route2 = function() { $.ajax({ url: "http://localhost:8070/api/route2", type: "POST", dataType: "json", data: { var1: val1 }, success: function (res) { // Various tasks if(res.flag){ $("#divContent1").hide(); $("#divContent2").show(); } else{ $("#divContent1").show(); } //Functions that handle div content data }, beforeSend: function() { $("#divContent1").hide(); $("#divContent2").hide(); }, complete: function() { setTimeout(route2,5000); }, }); }; $(function(){ route2(); }) }); }); &lt;/script&gt;</pre><p> setTimeout() 調用整個route2來處理div內容的所有顯示和插入。 但是,要求僅顯示第二次調用的divContent2 。</p><p> 尋找解決方案</p></div> 輸入密碼顯示div內容 顯示Div中的可折疊內容 如果存在具有特定類別的div,則顯示內容
 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM