Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# CSS
I have a floating div on page whose left is calculated by expression
left: expression( document.body.clientWidth - 9 - ( this.style.width.substr( 0, this.style.width.length - 2 ) ) + 'px' );
this expression is working fine in IE all versions but not in chrome and mozilla.
 
So, can any body help me to find the equivalent to that expression which can works in all three browsers.
 
Thanks In advance
Posted 16-Dec-12 18:54pm
Comments
Sergey Alexandrovich Kryukov at 17-Dec-12 1:04am
   
The rule is: if something works in both Chrome and Mozilla but not IE, it still may be correct. If it works in IE but fails either in Chrome or Mozilla, it's almost certainly incorrect.
And I'm pretty much sure that floating div can be avoided. One advice: use jQuery. It is designed with compatibility in mind.
—SA
Member 8128040 at 17-Dec-12 1:09am
   
ok so can u please help me to find the equivalent expression to find left for div as per the screen of the client, which works in both chrome and mozilla.
Sergey Alexandrovich Kryukov at 17-Dec-12 1:14am
   
First of all, is this expression in CSS? Or do your use JavaScript?'
—SA
Member 8128040 at 17-Dec-12 1:24am
   
Yes this is in CSS
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
try this out in your jquery section with in script tag.
 
$("#DivID").css("left",( document.body.clientWidth - 9 - ( this.style.width.substr( 0, this.style.width.length - 2 ) ) + 'px' );
 
Thanks
  Permalink  
v2
Comments
Member 8128040 at 17-Dec-12 6:06am
   
How can i use this expression in separate(common) css file.
Member 8128040 at 17-Dec-12 6:22am
   
After adding this in my code i m getting 0x800a138f - Microsoft JScript runtime error: Unable to get value of the property 'width': object is null or undefined
Error please help me out Armando
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I replace existing css
 
.PageMessageIFrame
{
z-index: 1003;
position: absolute;
left: expression( document.body.clientWidth - 5 - ( this.style.width.substr( 0, this.style.width.length - 2 ) ) + 'px' );
}
 
with this css
 
.PageMessageIFrame
{
z-index: 1003;
position: absolute;
bottom : 0px;
right : 0px;
}
 
Thanks to all...
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Sorry I was so late with the answer and answering when you already have your own solution. I strongly suspected CSS expressions was a bad thing; here is some justification, good to know:
http://gtmetrix.com/avoid-css-expressions-pagespeed.html[^],
http://msdn.microsoft.com/en-us/library/ms537634%28v=vs.85%29.aspx[^],
http://developer.yahoo.com/blogs/ydn/posts/2007/07/high_performanc_6/[^].
 
Good luck,
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 6,656
1 Sergey Alexandrovich Kryukov 6,490
2 CPallini 5,310
3 George Jonsson 3,584
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web03 | 2.8.140921.1 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100