Forum Moderators: open

Message Too Old, No Replies

How to make graphics in frames position correctly cross-browser

a browser-dependent server-side hack in PHP

         

david752

6:38 pm on Mar 25, 2002 (gmt 0)

10+ Year Member



My site <url snipped> uses frames, and while creating it I noticed that some of the frames were not positioned correctly in certain browsers. I couldn't solve the problem in Javascript for all common browsers (reasons omitted here). My solution is to use PHP code (if your server is Windows-based, use ASP instead) to move the frames.

The PHP code generates the proper frameset HTML.

Here is my code, simplified from the original. The specific offsets 4 and 6 may not work for you. The variables $IE, etc., indicate what kind of browser is running.

<?php
$width = 199;
$height = 129;

if ($IE ¦¦ $NS6 ¦¦ $OP)
$width = $width - 4;
if ($IE ¦¦ $OP)
$height = $height - 6;
?>
...
<frameset id=Frameset1 rows="<?=$height?>,*">
...

David

(edited by: tedster at 10:57 pm (utc) on Mar. 25, 2002)

tedster

11:08 pm on Mar 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the tip, david. Since this works server side, it's a more universal fix than using javascript.

Still, if you have a moment, I'd like to hear why Javascript couldn't deal with the issue in this case.

david752

4:19 pm on Mar 26, 2002 (gmt 0)

10+ Year Member



The short answer is that not all browsers will allow Javascript to manipulate a Frameset Node. Furthermove, in some browsers Frameset Nodes can be addressed, but their pixel widths/heights and/or pixel positions are not exposed as attributes.

David