javascript - Making a div on the top push all other content down -


i'm programming firefox plugin shows div on top page , pushes other content down. tried put before head tag doesn't seem work.

my code:

var alldivs = document.getelementsbytagname('div'); var headtag = document.getelementsbytagname('head')[0];  if (alldivs.mainplugindiv) {   alert("!!! plugin llibrowser running !!!"); } else {   var div = document.createelement('div');   div.id='mainplugindiv';   div.style.position = 'absolute';   div.style.zindex = '100';   div.style.width = '100%';   div.style.height = '150px';   div.style.background = '#313192';   div.style.color = 'white';   div.innerhtml="<script type=\"text/javascript\"   src="+self.options.angularlib+"></script>"+ "<script type=\"text/javascript\" src="+self.options.angularapp+"></script>"+   "<form style=\"margin: 0 auto; left: 10px; top: 50px; width: 98%;align: middle; visibility: visible\">"+     "<label for=\"video\" style=\"color: white\"> <input type=\"checkbox\" checked=\"checked\" name=\"video\" value=\"video\" id=\"video\" /> video</label>"+     "<label for=\"forum\" style=\"color: white\"> <input type=\"checkbox\" checked=\"checked\" name=\"forum\" value=\"forum\" id=\"forum\" /> forum</label>"+     "<img src="+self.options.closeimg+" alt=\"help\" style=\"width:20px;height:20px;\" align=right onclick=\"var yousure=confirm('are sure want close plugin?'); if (yousure){var element = document.getelementbyid('mainplugindiv');element.outerhtml = '';delete element;}\">"+     "<img src="+self.options.helpimg+" alt=\"close\" style=\"width:20px;height:20px;\" align=right onclick=\"alert('llibrowser')\">"+   "</form>"+   "<div style=\"margin: 0 auto; left: 10px; top: 50px; width: 98%; height: 50%; align: middle; background-color:#75bbf7; visibility: visible\">"+     "<div ng-show=\"tab == 1\">"+       "<form>"+         "<h3 style=\"color: white; align: center\">video1 video2 video3 video4</h3>"+       "</form>"+     "</div>"+     "<div ng-show=\"tab == 2\">"+       "<form>"+         "<h3 style=\"color: white; align: center\">forum1 forum2 forum3 forum4</h3>"+       "</form>"+     "</div>"+   "</div>"+   "<form style=\"margin: 0 auto; left: 10px; top: 50px; width: 98%;align: middle; background-color:#313192; visibility: visible\">"+   "<a href=\"#video\" style=\"color: white; background-color: #75bbf7; height: 15px; padding: 5 auto\" ng-click=\"tab = 1\">video</a>"+   "<a href=\"#forum\" style=\"color: white; background-color: #313192; height: 15px; padding: 5 auto\" ng-click=\"tab = 2\">forum</a>"+   "</form>";   headtag.parentnode.insertbefore(div, headtag); 

thanks!

instead of setting position absolute set relative , clear both sides.

div.style.position = 'relative'; div.style.clear = 'both'; 

this should work.

edit : instead of appending in head tag, make first child of yourbody

document.body.insertbefore(div,body.firstchild); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -