Welcome Guest, Not a member yet? Register   Sign In
detect JS with CI?
#1

[eluser]mr_coffee[/eluser]
Possibly... what I'm doing here is bad form to begin with, but lets pretend it isn't for a second.

I have a default file for css, I load it in the head as usual. I have TWO other css files for screen resolution 800x600 and 1024x768. Since images and margins were involved, I figured this was the simplest solution. To prevent a massive delay during resize and multiple wasted image loads, I loaded one of the other two files with JS dependent on screen resolution. BUT... there's a drawback... of course. If JS isn't enabled, the user won't load either of the two files and the page will be ugly. I don't care so much that the page is ugly... but because I'm psychotic and made the navigation menu entirely out of graphics... and one of these two files is choosing the graphics... well... yeah. I don't want a user without javascript enabled to see NOTHING where the menu goes. I'd rather have it load the BIG version of the site all fuglified.

What works but doesn't validate xhtml strict:
Code:
<noscript>
&lt;?php echo link_tag('1024x768.css'); ?&gt;
</noscript>

So I did some searching, and found a novel solution to this: make two php files. Call one as javascript and have it set a session variable. Call the second as css and if that variable is set, display one css file, if it doesn't display a different one. This method, while quite effective, didn't take into account the possibility that I'm already manipulating a php file. Here's what I think SHOULD work, but doesn't:

Made a file checkforjs.php:
Code:
&lt;?php
    $_SESSION['JavaScript'] = true;        
?&gt;

Modified the head of the page (in my view) like so:
Code:
&lt;?php echo link_tag('default.css'); ?&gt;
&lt;?php
  if (!(isset($_SESSION['JavaScript']))) {
      echo link_tag('1024x768.css');
  }        
?&gt;

Thing is... it's always going to throw on the 1024x768.css file since this is in a view file... CI is loading the page for the client before the client loads the checkforjs.php file and so the variable won't be set before the view looks to see if there's a value for it, js enabled or not. I feel there should be a terribly simple solution built into CI that I just haven't noticed and wondered if someone else had an idea. Maybe there's something I can do with the controller to affect the view of the header file, etc. Let me know please?


Messages In This Thread
detect JS with CI? - by El Forum - 04-24-2008, 11:50 AM
detect JS with CI? - by El Forum - 04-25-2008, 12:56 AM
detect JS with CI? - by El Forum - 04-25-2008, 01:52 AM
detect JS with CI? - by El Forum - 04-25-2008, 03:54 PM
detect JS with CI? - by El Forum - 04-25-2008, 09:15 PM
detect JS with CI? - by El Forum - 04-25-2008, 09:57 PM
detect JS with CI? - by El Forum - 04-25-2008, 10:28 PM
detect JS with CI? - by El Forum - 04-26-2008, 10:17 AM
detect JS with CI? - by El Forum - 04-26-2008, 11:02 AM
detect JS with CI? - by El Forum - 04-26-2008, 11:55 AM
detect JS with CI? - by El Forum - 04-26-2008, 01:09 PM
detect JS with CI? - by El Forum - 04-26-2008, 01:44 PM
detect JS with CI? - by El Forum - 04-27-2008, 11:42 AM
detect JS with CI? - by El Forum - 04-27-2008, 12:02 PM
detect JS with CI? - by El Forum - 04-27-2008, 01:17 PM
detect JS with CI? - by El Forum - 04-27-2008, 02:02 PM
detect JS with CI? - by El Forum - 04-27-2008, 02:06 PM
detect JS with CI? - by El Forum - 04-27-2008, 03:58 PM
detect JS with CI? - by El Forum - 04-27-2008, 04:03 PM
detect JS with CI? - by El Forum - 04-27-2008, 04:54 PM
detect JS with CI? - by El Forum - 04-27-2008, 10:43 PM
detect JS with CI? - by El Forum - 04-28-2008, 05:15 PM
detect JS with CI? - by El Forum - 04-29-2008, 09:00 AM
detect JS with CI? - by El Forum - 04-30-2008, 08:03 AM
detect JS with CI? - by El Forum - 04-30-2008, 08:26 AM
detect JS with CI? - by El Forum - 04-30-2008, 09:11 AM
detect JS with CI? - by El Forum - 04-30-2008, 11:59 AM
detect JS with CI? - by El Forum - 04-30-2008, 04:56 PM
detect JS with CI? - by El Forum - 08-11-2009, 04:13 PM



Theme © iAndrew 2016 - Forum software by © MyBB