DIV自动高于另一个DIV

DIV above another DIV automatically

本文关键字:DIV 另一个 高于      更新时间:2023-09-26

我需要一个脚本,当页面加载时,它会在另一个div之上添加一个div,并且我需要能够直接在Javascript代码中编辑div的html编码(对于用户脚本)。目前,我用它来替换div,这有点乱。

if (document.getElementById ('category_45'))
{
    var wdiv = document.getElementById ('category_45');
    wdiv.innerHTML = '<div id=shoutboxfix><iframe id=reloader name=reloader scrolling=yes frameborder=0 width=1000px height=350px src=http://forums.digitalwarfare247.com/index.php?/shoutbox/index.php#category_shoutbox>';
    wdiv.innerHTML += '<input type="button" value="Refresh ^" onclick="parent.top.reloader.location.reload(true);" /></div>';
    wdiv.innerHTML += '<br />';
}

我需要的div上面的新div的ID是'category_45',HTML编码是<iframe id=reloader name=reloader scrolling=yes frameborder=0 width=1000px height=350px src=http://forums.digitalwarfare247.com/index.php?/shoutbox/index.php#category_shoutbox>

感谢所有帮助你的人。

您考虑过JQuery吗?http://api.jquery.com/before/

或者Mootools?

myThirdElement.inject(mySecondElement, 'before');

来源:http://mootools.net/docs/core/Element/Element#Element:inject