简体   繁体   English

DIV自动高于另一个DIV

[英]DIV above another DIV automatically

I need a script that will add a div above another div when the page loads, and I need to be able to edit the DIV's html coding directly inside the Javascript code (for a userscript). 我需要一个脚本,该脚本将在页面加载时在另一个div上方添加一个div,并且我需要能够直接在Javascript代码(对于用户脚本)内部编辑DIV的html代码。 Currently, I have it replacing a div, and it's kind of a mess. 目前,我有它替代了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 />';
}

The div I need the new div above's ID is 'category_45', and the HTML coding is <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> 的div我需要上面的ID的新div是'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>

Thanks to anyone that helps. 感谢任何有帮助的人。

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

Or perhaps Mootools ? 还是Mootools?

myThirdElement.inject(mySecondElement, 'before');

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM