Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryWeb Page and Site Features

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Responsive-Width Assistant

Checking a web page to see if it looks good displayed in browser windows at various widths can be time consuming.

The page may be viewed with a phone, portrait and landmark orientations. Perhaps with a tablet. And on a desktop with various browser widths.

Toward the end of development, when final touches are being done, it generally is prudent to do all that viewing with every tweak.

To save some time on a project, last week, I built a responsive-width assistant. It does not emulate other devices or browsers. It's entire purpose is to see how a web page responds with the viewport at various widths.

The assistant is an iframe on a web page. The web page is displayed in a wide browser window on the desktop.

Above the iframe is a text field to type or paste in the URL to check.

Below the iframe are radio buttons to change the iframe width.

Within the iframe is the web page to be tested. The radio buttons are clicked to see how the page looks at certain widths.

I find it pleasant to use. You may, too.

Here is a working installation. The default iframe width is 320 pixels, which you may change.

Specify a URL above the iframe and select a width below the iframe. (You'll need to tap anywhere outside the URL text field so the browser knows you are done typing.)

As you select different widths, you'll see how the web page responds.

URL:
Width:

You may use the Responsive-Width Assistant right here at this web page. Or, you may install it on your own website.

If you elect to install it on your website, here is the source code.

<div style="max-width:500px; border:3px solid #ccc; border-radius:1em; padding:.5em; margin-bottom:5px;">
URL: 
<input 
   type="text" 
   value="https://lightfocus.com/friday-photo-series/good-morning.php" 
   id="iframe-url" 
   onchange="ChangeURL()" 
   style="width:100%; border:1px solid #ccc; border-radius:5px; padding:.5em;">
</div>
<iframe id="i-frame" 
   style="height:500px; border:1px solid black;" 
   src="">
</iframe>
<div style="border:3px solid #ccc; border-radius:1em; display:table; padding:.5em;">
Width: 
<label><input type="radio" name="width" onclick="ChangeWidth(320)" checked="checked">320</label> 
<label><input type="radio" name="width" onclick="ChangeWidth(450)">450</label> 
<label><input type="radio" name="width" onclick="ChangeWidth(550)">550px</label> 
<label><input type="radio" name="width" onclick="ChangeWidth(700)">700px</label>
</div>
<script>
function ChangeWidth(n) { document.getElementById("i-frame").style.width=n+"px"; }
function ChangeURL() { document.getElementById("i-frame").src=document.getElementById("iframe-url").value; }
ChangeWidth(320); // Specifies default width.
ChangeURL();
</script>

Paste the source code into a plain text file, name the file ResponseWidthAssistant.php (or other *.php file name), and upload the file to your server. Type its URL into your browser and you're ready to go.

The default web page may be changed. Find this code in the source code above

<input 
   type="text" 
   value="https://lightfocus.com/friday-photo-series/good-morning.php" 
   id="iframe-url" 
   onchange="ChangeURL()" 
   style="width:100%; border:1px solid #ccc; border-radius:5px; padding:.5em;">

and change the purple URL to the URL of your choice.

If you wish to add more radio button options, make a copy of this line

<label><input type="radio" name="width" onclick="ChangeWidth(550)">550px</label> 
and insert it where the other buttons are. Then change both instances of 550 to the width you prefer.

The Responsive-Width Assistant is actually kinda fun to use, just to see how various web pages respond. Now may be a good time to check each of your websites.

Enjoy. :-)

This article first appeared with an issue of the Possibilities newsletter.

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC