0
Welcome Guest! Login
0 items Join Now

responsive to change script launch

  • responsive to change script launch

    Posted 11 years 10 months ago
    • Hello
      I use the responsive css function of gantry (Hexeris ”flower” template), to hide or show module and it’s work well.
      But for a particular page, I need to run a script on opening a page and I need that theses script launch just when the request comes from desktop presentation (and not from mobile). In this case the css don’t work because the block is just hided but the code load. I see some discussions about gantrymobiledetect.class.php But it’s a little difficult for me to install it, and he test the machine, and not what I’m looking for that is the media larger.
      Is there the possibility to read the value of the @media page is being loaded from the php code?
      In this case I could (using sourcing) integrate a simple php code that tests the value @ media, and following the response starts or not the script. I am also certain that it would be nice to integrate a gantry at the same way as the CSS code to manage the responsive.
      Thanks
      Gerard
      ( masdevence.azurline.com )
    • Gerard Grazzini
      masdevence.azurline.com
    • Shazdeh's Avatar
    • Shazdeh
    • Elite Rocketeer
    • Posts: 4984
    • Thanks: 29

    Re: responsive to change script launch

    Posted 11 years 9 months ago
    • Hi,
      to the best of my knowledge PHP does not offer a way to detect the user's screen resolution.
      Are you using JavaScript for that "run a script on opening a page"? In that case you can just use window.getWidth() to get the maximum available size of the window. Then you can do an if condition to run that script only if the window's size is larger than a certain amount:
      if( window.getWidth() > 1000 ) {
           // run the script
      }
      This way the script only runs when the window size is larger than 1000 pixels.
    • Please don't PM unless requested ;)
      Consider using the custom stylesheet for all your CSS customizations: gantry-framework.org/documentation/wordp...custom_stylesheet.md .
      Please provide the URL to the issue.
      And please mark the thread as solved if the issue is resolved.

Time to create page: 0.067 seconds