I have the following code:
<script type="text/javascript">
$(document).ready(function() {
$('<div id="tools" style="text-align:right;float:right;"><input type="button" value="Print this page" onclick="window.print();return false;" /><input type="button" value="Save this page" onclick="go_saveas();return false;" /></div>').insertBefore('body');
});
</script>
Basically, I need to insert that whole Div just right after the <body>
tag:
</head>
<body>
<div id="tools"..
...
Which works in Firefox but doesn't work in IE 7, what do I have to change to fix this?
You're using insertBefore
. That will try to put it between head
and body
; not what you want. Try prependTo
.
http://jsfiddle.net/XDFMt/:
<script type="text/javascript">
$(document).ready(function() {
$('<div id="tools" style="text-align:right;float:right;"><input type="button" value="Print this page" onclick="window.print();return false;" /><input type="button" value="Save this page" onclick="go_saveas();return false;" /></div>')
.prependTo('body');
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With