0
У меня есть следующий сценарий для создания IFRAMEНевозможно вызвать метод «AppendChild» нуля для фреймов
function createIframe() {
var iframe = document.createElement("iframe");
iframe.style.position = "absolute";
iframe.style.visibility = "hidden";
document.body.appendChild(iframe);
// Firefox, Opera
if(iframe.contentDocument) iframe.doc = iframe.contentDocument;
// Internet Explorer
else if(iframe.contentWindow) iframe.doc = iframe.contentWindow.document;
// Magic: Force creation of the body (which is null by default in IE).
// Also force the styles of visited/not-visted links.
iframe.doc.open();
iframe.doc.write('<style>');
iframe.doc.write("a{color: #000000; display:none;}");
iframe.doc.write("a:visited {color: #FF0000; display:inline;}");
iframe.doc.write('</style>');
iframe.doc.close();
// Return the iframe: iframe.doc contains the iframe.
return iframe;
}
однако в хромированной консоли он дает мне ошибку не удается вызвать метод «AppendChild» нулевой
Почему он не работает?
Когда вы получите сообщение об ошибке? Я запустил его на своей консоли Chrome, это сработало! Просто проверьте, '' document.createElement ("iframe"); 'возвращает элемент! – NINCOMPOOP