Menu
JAQForum Ver 19.10.27

Forum Index : Microcontroller and PC projects : Web page design

Posted: 12:48am
05 Oct 2025
Copy link to clipboard
palcal
Guru


Hi all, this is a bit different. I have designed a web page but am having trouble getting it to fit any browser size. On my desktop it is ok but on the smaller laptop screen I have to scroll every way to see it all. I used the following code but it didn't work. It is a public site, I am new to this and get lost easily.

meta name="viewport" content="width=device-width, initial-scale=1.0">
.
Can anyone help.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
Posted: 01:24am
05 Oct 2025
Copy link to clipboard
Gizmo
Admin Group


The issue is some browsers ( looking at you in particular Safari ), dont necessarily take any notice of your meta tags.

In my JAQ intranet application, I use the following java to resize the page to the browser window on mobile devices. Its not perfect.

In the body tagI call a function like this....


<body onLoad="PageZoom();">
 <div style="width:330px; margin:auto;" id="PageDiv">
   Blah blah


That div encases the entire page in the body tag. You can control the width with that style "width:330px", but its not necessary. In this case its a generic mobile phone width so I can check th epages looks ok on a mobile screen as I develop the page.

Then elsewhere on the page, usually in the header somewhere, I have...

<script language="javascript">
function PageZoom(){
 var DivW=document.getElementById("PageDiv").offsetWidth;
 var PageW=window.innerWidth;
 Z= Math.round(PageW / DivW * 95);
 Zstring=Z.toString() + "%";
 document.body.style.zoom = Zstring;
 document.getElementById("PageDiv").focus();
}
</script>


Once the page has loaded, it gets the width of the div "PageDiv", and then adjusts the zoom to suit.

Glenn
Edited 2025-10-05 11:27 by Gizmo
 
Posted: 01:56am
05 Oct 2025
Copy link to clipboard
palcal
Guru


I'll try that,  thanks.

EDIT.... That didn't work, I don't know enough about HTML ,so I can just put up with it.
Edited 2025-10-05 14:20 by palcal
 


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025