473,378 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

problem in applying platform specific css

hi,

this is deepak, i got stuck in a script where i want to apply a platform specific css. i will be greatful if anyone could help me out.

My PHP code is:
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $agent = getenv("HTTP_USER_AGENT");
  3.  
  4. if (preg_match("/Win/i", "$agent")){
  5. $style = "win";
  6. //echo "matched window";
  7. }else if (preg_match("/Linux/", "$agent")){
  8. $style = "linux";
  9. //echo "matched linux";
  10. }
  11. $win_style = "
  12. <style1 type = \"text/css\">\n
  13. p, ul, ol, li {font family:Arial;font-size:20pt;font-weight:normal;}\n
  14. h1 {font family:Arial;font-size:16pt;font-weight:bold;}\n
  15. h2 {font family:Arial;font-size:14pt;font-weight:bold;}\n
  16. strong {font family:Arial;font-size:10pt;font-weight:bold;}\n
  17. em {font family:Arial;font-size:10pt;font-style:italic;}\n
  18. </style1>
  19. ";
  20.  
  21. $linux_style = "
  22. <style1 type = \"text/css\">\n
  23. p, ul, ol, li {font family:Times;font-size:10pt;font-weight:normal;}\n
  24. h1 {font family:Times;font-size:18pt;font-weight:bold;}\n
  25. h2 {font family:Times;font-size:16pt;font-weight:bold;}\n
  26. strong {font family:Times;font-size:12pt;font-weight:bold;}\n
  27. em {font family:Times;font-size:12pt;font-style:italic;}\n
  28. </style1>
  29. ";
  30. ?>
  31.  
  32. <html>
  33. <head>
  34. <title>Platform Matching</title>
  35. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  36. </head>
  37. <body>
  38. <?
  39. if($style == "win"){
  40. echo "$win_style";
  41. $style = "$win_style";
  42. }else if($style == "linux"){
  43. echo "$linux_style";
  44. $style = "$linux_style";
  45. }
  46. ?>
  47. <h1 align=center> This is a level 1 heading </h1>
  48. <h2 align=center> Look! a level 2 heading</h2>
  49. <p align=center> this a simple paragraph with some <strong> bold </strong> and <em> emphasized</em> text.</p>
  50. </body>
  51. </html>
Jul 20 '07 #1
3 946
Where are you getting stuck?

What happens when you open the page?
Jul 20 '07 #2
i am facing a challenge, when i change my stylesheet example: font size but it is not showing the updated font size.
Jul 21 '07 #3
kovik
1,044 Expert 1GB
What are you doing in the script?

Firstly, don't get into the habit of putting quotes around variables. You can do away with them.
Secondly, you should put your CSS into external files. It's halfway pointless to use CSS if you're still loading them into the actual HTML file. The purpose is to separate style from content.
And thirdly, why are you serving a different page depending on the user agent? Do you know how easy it is to spoof a user agent? Use Firefox or Opera and try it.

I'd do away with this idea completely, especially since you don't have an alternative for when the user agent doesn't contain win or linux.
Jul 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Coca | last post by:
HI, all How can I convert the C6.0 program of OS/2 platform TO windows2000/xp platform. The program occurs a lot of errors in Windows 2000/xp when compiled. And I hope a quick way to solve...
1
by: Rahul Iyer | last post by:
G'day I have encountered quite a strange problem with a new function i've added to an existing software. Pseudo code of actions. -- begins -- func_foo (){
34
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
5
by: vjonweb | last post by:
Hello! I am facing an extremely frustrating problem with command line arguments...I have no clue why it is happening. Any help will be greatly appreciated. My program: "a.c"...
16
by: Andy | last post by:
Hi, I have read that 'C' is platform-independent and portable. I can'tsee much a difference between the two terms. Could anyone differentiate the two? Also is the statement actually true? Thanks...
1
by: /M | last post by:
Hi! As you know, one way to seperate platform dependent code from platform _independent_ code is to create an abstract base class which acts as an interface towards all platform independent code...
17
by: Michael Reichenbach | last post by:
Here is the example code. int main(int argc, char *argv) { string Result; WIN32_FIND_DATA daten; HANDLE h = FindFirstFile(TEXT("c://test"), &daten); system("PAUSE"); return EXIT_SUCCESS; }
1
by: deepakNagpal | last post by:
hi, this is deepak, i got stuck in a script where i want to apply a platform specific css. i will be greatful if anyone could help me out. My PHP code is: <?php $agent =...
3
by: saneman | last post by:
I have read that Python is a platform independent language. But on this page: http://docs.python.org/tut/node4.html#SECTION004220000000000000000 it seems that making a python script...
5
by: yoavrofe | last post by:
Hello all, I'm trying to run a small program on both PPC and CE devices. I am calling SHGetAutoRunPath only when running on a PPC platform. However, since this function depends on aygshell.dl,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.