Click here to Skip to main content
16,004,761 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Comments
Sergey Alexandrovich Kryukov 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 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 17-Dec-12 1:14am    
First of all, is this expression in CSS? Or do your use JavaScript?'
—SA
Member 8128040 17-Dec-12 1:24am    
Yes this is in CSS

Hi,

try this out in your jquery section with in script tag.

CSS
$("#DivID").css("left",( document.body.clientWidth - 9 - ( this.style.width.substr( 0, this.style.width.length - 2 ) ) + 'px' );


Thanks
 
Share this answer
 
v2
Comments
Member 8128040 17-Dec-12 6:06am    
How can i use this expression in separate(common) css file.
Member 8128040 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
[no name] 17-Dec-12 7:16am    
Please share your requirement here properly.
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...
 
Share this answer
 
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900