0
我的jsfiddle:http://jsfiddle.net/gCRuk/1/如何使用javascript將樣式表從父級添加到iFrame?
HTML:
My replays on SC-Replay.com:<br>
<iframe frameborder="0" name="frame" id="frame1" src="http://www.sc-replay.com/embedPlayer/21368-TheLindyHop.html" style="left: 0pt; position: relative; top: 0pt; width: 980px; height: 500px; border: 0px solid #00214E;" n="" vspace="0" marginheight="0" marginwidth="0" hspace="0" allowtransparency="true"></iframe>
的Javascript:
var ss = document.createElement("link");
ss.type = "text/css";
ss.rel = "stylesheet";
ss.href = "http://www.lprestonsegoiii.com/WordPress/wp-content/themes/arjuna-x/style.css";
var iframe;
if(document.frames)
iframe = document.frames["frame"];
else
iframe = window.frames["frame"];
if(document.all)
iframe.document.createStyleSheet(ss.href);
else
iframe.document.getElementsByTagName("head")[0].appendChild(ss);
我遵循這個指南:http://www.geekdaily.net/2007/09/19/javascript-adding-a-stylesheet-to-an-iframe/
而且我真的不知道這裏發生了什麼/出了什麼問題。