views:

252

answers:

2

I found javascript solution for removing gridlines on Google docs spreadsheets (using "download as HTML" and then past javascript in Web Address Bar): works great !!

javascript:var v="none",e="defaultView",o="border",m="Color",w=function(a,b){if(document[e]){if(document[e].getComputedStyle(a,null)[o+b+m]=="rgb(204, 204, 204)")a.style[o+b]=v}else if(a.currentStyle[o+b+m]=="#ccc")a.style[o+b]="none"},q=function(a){a=window.document.getElementsByTagName(a);for(var b=0;b<a.length;b++){var c=a[b];w(c,"Left");w(c,"Right");w(c,"Bottom");w(c,"Top")}};q("td");q("table");

Was wondering if it is possible to make a comparable javascript to remove the header and footer for docs "publised" to the web?! Published spreadsheets have a -> header: filename + sheetname; -> footer: "Edit this page (if you have permission) – Published by Google Docs – Report Abuse – Updated automatically every 5 minutes" -> example: TEST (I already added "&gridlines=false" to the url to remove gridlines).

Why is previous solution not sufficient ?! *I want some people to view and print the result of a spreadsheet (via publish to web) without giving them access (view) to the spreadsheet itself. Therefore they can't use "download as HTML" + your javascript, but want to provide a url to view a published site and be able to make a neat print without the Google header and footer.*

Would be great if anyone could help out!

Regards,

+2  A: 

Thankfully the layout on this page is super simple.

<div id="header">...</div>
<div id="content">...</div>
<div id="footer">...</div>

You could write a function like this to hide the header and footer.

var f = function(id)
{
    document.getElementById(id).style.display = "none";
};
f("header");
f("footer");

Or the copy paste version:

javascript:var f=function(id){document.getElementById(id).style.display="none";};f("header");f("footer");
Joel Potter
A: 

I would like to make both of these changes (hide gridlines when published and remove header/footer) but I'm a newbie and can't follow the instructions provided. My google doc is embedded into a web page through my wordpress account within an iframe tag.

where do i add the two pieces of javascript language?

Albert