The following JavaScript is working fine in older versions of Safari (Safari 3), but not on latest version of Safari.
Can you help me find the problem?
function loadframe(){
var iframeEl = document.getElementById("ifrm");
if(!iframeEl)
{
window.alert('hellooooooo');
var el = document.createElement("div");
el.innerHTML = '<iframe id="ifrm" width="0" height="0" src=\'<!--EP CLASS="com.epiphany.presentation.ServerURLWriter" ACTION="campaign_segment_load" TE开发者_运维问答MPLATE="campaign\\campaign_segments" -->\' onload="dw_display(\'ifrm\',\'segmentspn\')" ></iframe>';
document.body.appendChild(el);
return true;
}
return false;
}
function loadframe()
{
var iframeEl = document.getElementById("ifrm");
if(!iframeEl)
{
var el = document.createElement('div');
var e2 = document.createElement('iframe');
e2.src ="http://google.com";
e2.setAttribute('id',ifrm);
e2.width= 80;
e2.height= 80;
document.body.appendChild(el);
el.appendChild(e2);
return true;
}
return false;
}
This will work on all browser, As iframe is another element, we should add it using DOM's method.
精彩评论