[Using Sakai] Use default style sheets in HTML resources

Steve Swinsburg steve.swinsburg at gmail.com
Sun Jan 30 04:29:05 PST 2011


Hi Norman,

You can add a piece of Javascript to the top of your HTML (you'll need to 'view source') which makes the HTML page inherit the styles from the parent page, necessary since it's iframe based. I just tested this and it still works:

<script language="JavaScript" type="text/JavaScript">
var i, a, href
for(i=0; (a = top.document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1) {
if(a.getAttribute("href").indexOf("portal") != -1) {
//normal - top is portal
document.write ('<link href=\"');
document.write (a.getAttribute("href").substring(0,a.getAttribute("href").indexOf("portal")));
document.write ('tool.css\" type=\"text/css\" rel=\"stylesheet\" media=\"all\" />');
document.write ('<link href=\"');
document.write (a.getAttribute("href").substring(0,(a.getAttribute("href").indexOf("skin") + 5 )));
document.write ('tool_base.css\" type=\"text/css\" rel=\"stylesheet\" media=\"all\" />');
}
else
{
//not normal - top is something else - use it's stylesheets
document.write ('<link href=\"');
document.write (a.getAttribute("href"));
document.write ('" type=\"text/css\" rel=\"stylesheet\" media=\"all\" />');
}
}
}
</script>

cheers,
Steve


On 29/01/2011, at 8:04 AM, Norman Danner wrote:

> I have some HTML pages on my Sakai course site that I create by making a 
> Web Resource tool point to an HTML page that is a resource for the site 
> (i.e., created with the Resources tool).  This is mostly fine, except 
> that the (CSS) style of the HTML that I write is rather different than 
> the rest of the course site.  For example, whereas most text on the site 
> is in a smaller sans-serif font, my HTML pages are in a comparatively 
> large serif font.  Since that HTML appears in a frame within the rest of 
> the site, the difference is especially jarring.
> 
> Is there a way to get my HTML to use the CSS that the rest of the site 
> is using?  I don't seem to be able to specify any CSS in the HTML 
> resource itself, because whenever I save the resource, any <head> 
> section is deleted, leaving just the <body>.
> 
> 	- Norman
> 
> -- 
> Norman Danner - ndanner at wesleyan.edu - http://ndanner.web.wesleyan.edu
> Department of Mathematics and Computer Science - Wesleyan University
> _______________________________________________
> sakai-user mailing list
> sakai-user at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-user
> 
> TO UNSUBSCRIBE: send email to sakai-user-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-user/attachments/20110130/e6728202/attachment.html 


More information about the sakai-user mailing list