Jump to content


Photo

How to simply retrieve the window height before generating page?


  • Please log in to reply
7 replies to this topic

#1 Drew_Tronvig

Drew_Tronvig

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 10 May 2014 - 07:43 PM

I have only the haziest understanding of AJAX, but at this point I just want to check the height of the browser window and get that into a PHP variable before I generate the actual page. Is there an example of that sort of thing posted somewhere? I'm working in Joomla, so jQuery is loaded.

 

Thanks,

Drew



#2 Rifts

Rifts

    Warlock

  • Members
  • PipPipPip
  • 713 posts
  • LocationAZ
  • Age:27

Posted 13 May 2014 - 09:23 PM

if your using jquery 
 

$(window).height();   // returns height of browser viewport
$(document).height(); // returns height of HTML document
$(window).width();   // returns width of browser viewport
$(document).width(); // returns width of HTML document


#3 Drew_Tronvig

Drew_Tronvig

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 13 May 2014 - 09:54 PM

i admit to knowing practically nothing about AJAX, but these look to me like they would be functions that could be used in javascript -- in the browser, of course. How would I then get these values back to PHP variables on the server? 



#4 Jacques1

Jacques1

    Advanced Member

  • Members
  • PipPipPip
  • 683 posts

Posted 14 May 2014 - 08:15 AM

If you know nothing about Ajax, how about learning it? jQuery has an excellent documentation. And of course there's Google with tons of additional explanations.

 

I don't see the point of repeating the same things that have already been written down thousands of times and are just waiting for you to read them.



#5 Drew_Tronvig

Drew_Tronvig

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 14 May 2014 - 02:02 PM

Well sure, and having a quick example performing a very simple comparable action would help get me up to speed in a hurry. Could you point me toward a minimal document that would do something like retrieving a screen dimension before generating the actual page? Or I could Google for hours in hopes of finding something like that.


Edited by Drew_Tronvig, 14 May 2014 - 02:04 PM.


#6 Drew_Tronvig

Drew_Tronvig

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 14 May 2014 - 03:12 PM

Not knowing the terminology, I'd love to get just terms to use in searching for a minimal document that would do something as simple as this.



#7 richei

richei

    Advanced Member

  • Members
  • PipPipPip
  • 90 posts

Posted 15 May 2014 - 03:12 AM

there should be a lot on stackflow. when I was looking for a way to center a div, it took me a few minutes to find it.

how much time it takes depends on what you search for. try http://stackoverflow...en-using-jquery (took 30 seconds to find btw)

#8 Drew_Tronvig

Drew_Tronvig

    Newbie

  • New Members
  • Pip
  • 5 posts

Posted 15 May 2014 - 04:40 AM

Yeah, I gave up trying to Google up an answer and asked the question at stackoverflow. I got a promising answer, and now I'm just trying to stitch together the parts from that answer into an actual working example.

 

I certainly appreciate the help here, but I was already pretty clear on how to get the values in via jquery. The trick is how to get those values back to the PHP script on the server, hence asking on the AJAX board.

 

Thanks,

Drew






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com