dynamically changing position attribute in ie7 with javascript

April 6th, 2007 by Joshua

If an element started out with a style=”position:absolute” attribute then changing the style to something else (e.g. this_element.style.position = ‘fixed’) was producing screwy results in ie7. Naturally no dramas in firefox.

The solution was to declare different classes with the styles I wanted and dynamically change the className attribute instead of the style attribute.


.fixed_style { position:fixed;}
.absolute_style { position:absolute;}

my_element.className = 'fixed_style';
my_element.className = 'absolute_style';

worked like a charm

window.pageYOffset not working in ie7

April 6th, 2007 by Joshua

yet another piece of ie6 specific javascript that is no longer working in ie7.

had to use document.documentElement.scrollTop;

thanks to http://forums.asp.net/thread/1633238.aspx

render view without an action in cakephp

April 6th, 2007 by Joshua

I wanted to render a view in cakephp but $this->render(’view_name’) only works if there is an action declared in the controller. I didn’t want to declare an action as I wanted to have the view passed as a parameter.

The solution was messy but it worked.
$vc = new View($this);
$file = $vc->_getViewFileName($_REQUEST['view']);
if (file_exists($file)) $this->render(null,null,$file);

css: position fixed in ie7

April 6th, 2007 by Joshua

Spent a couple of hours the other day trying to get fixed positioning to work in ie7. All the articles I could find said it was supported but it stubbornly refused to display.

The problem was no doctype in the html - added
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

to the top of the page and the css worked as expected.