0

Yes, this question is pretty much exactly like Javascript screen width/height to PHP But I can't get the answers (to that question or to several similar ones) to work in the context described below. That's probably due to my very, very limited knowledge of php, and next-to-nothing knowledge of js (I've just cut-and-pasted some js stuff that I didn't understand, and fiddled with it until it "just worked").

The php I have now just hard-codes the height for an <iframe>...

 <?php
   Blah; blah; blah;
   echo ' <iframe align="middle" width="99%" height="768"', "\n";
   echo $some_more_stuff_to_finish_iframe_tag, "\n";
 ?>

But what I really want is something like...

 <?php
   global $screenheight;
   $frameheight = $screenheight-100;
   Blah; blah; blah;
   echo ' <iframe align="middle" width="99%" height="';
   echo $frameheight,'"', "\n";
   echo $some_more_stuff_to_finish_iframe_tag, "\n";
 ?>

By the way, the reason for php to echo that iframe tag is that its src= attribute has to be dynamically constructed.

And I don't suppose that global $screenheight; I've illustrated is actually the php-side of the correct js-to-php mechanism. I just put it there as a "place-holder", so to speak. So, what is the correct mechanism and syntax -- both the js and php sides -- to accomplish this?

John Forkosh
  • 502
  • 4
  • 14
  • 1
    Why not set the iframe height in JS, upon page load? Something like `document.querySelector('selector_to_your_iframe').height = window.screen.height`. Still weird though as something like this can most likely be achieved via pure CSS. – Jeto Sep 02 '18 at 08:12
  • @Jeto Thanks. Yes, css would be >>great<<, though it's yet another markup I don't understand:) If I follow the gist of your suggestion, I'd add something like an _id=myframe_ attribute to the tag, and then set the window height for _myframe_ frames in css. So what's the css syntax for that? (sorry that I don't already know that) – John Forkosh Sep 02 '18 at 08:19
  • 1
    Something like `#myframe { height: 100%; }` I would guess. You should probably take basic tutorials/courses about these languages though as you won't go far if your lack the basics (not saying this to be mean). – Jeto Sep 02 '18 at 08:22
  • @Jeto Thanks again. Tried it, but not immediately working. However, googling again, along with "css" , led me to additional questions like https://stackoverflow.com/questions/9975810/ And although that's not immediately working, either, it gives me lots more to mess around with. – John Forkosh Sep 02 '18 at 09:05

0 Answers0