0
我在我的頁面上嵌入了一些Google地圖嵌入代碼;這些讓我的頁面變慢,所以我想在加載頁面後加載它們,所以我正在嘗試這樣的事情。不幸的是,地圖的iframe來源發生了變化,但地圖不會在裏面加載,只是空白。動態加載iframe源代碼
例如鏈接:
<iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.co.in/maps?f=q&source=s_q&hl=en&geocode=&q=Megarugas+Banquet+and+Lawn,+Opp.+Chandivali+studio,&aq=&sll=19.127228,72.865035&sspn=0.013259,0.022724&ie=UTF8&hq=Megarugas+Banquet+and+Lawn,+Opp.+Chandivali+studio,&hnear=&t=m&cid=15174344858031542989&ll=19.115165,72.894802&spn=0.024329,0.025663&z=14&iwloc=A&output=embed"></iframe><br /><small><a href="https://maps.google.co.in/maps?f=q&source=embed&hl=en&geocode=&q=Megarugas+Banquet+and+Lawn,+Opp.+Chandivali+studio,&aq=&sll=19.127228,72.865035&sspn=0.013259,0.022724&ie=UTF8&hq=Megarugas+Banquet+and+Lawn,+Opp.+Chandivali+studio,&hnear=&t=m&cid=15174344858031542989&ll=19.115165,72.894802&spn=0.024329,0.025663&z=14&iwloc=A" style="color:#0000FF;text-align:left">View Larger Map</a></small>
HTML:
<iframe id="blabla"></iframe>
JS:
$(window).load(function() {
if ($('#blabla').length <= 0) { return; } // to avoid errors in case the element doesn't exist on the page/removed.
$('#blabla').attr('src','//example.com/page');
});
是的,這解決了問題... thnx再次 – warlock