<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Media Queries</title>
        <description> Hi,

First off, I am a novice at programming but have a good grip on Webdev so far. I am trying build a &amp;#039;responsive website&amp;#039;, but I am struggling to detect the browser width.

Fabrice Harari was kind enough to give me his js code:

function JSGetBrowserWidth()
{
	// return document.body.clientWidth;
	var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
	return w
}

Not knowing how to code/handle js. I have pasted the code in my home page&amp;#039;s browser code (which is flipped to JS : blue). After this I have no idea what to do....

Can anyone help me detect a browser&amp;#039;s width so that I can adjust my content depending on the device that is being used?

Webdev 7-79p
Webdev Dynamic Site
Target Platform: Any

Thanks in advance to all the pro Webdevers!
NH</description>
        <link>https://www.wxforum.info/read.php?27162,164128,164128#msg-164128</link>
        <lastBuildDate>Tue, 19 May 2026 03:21:23 +0200</lastBuildDate>
        <generator>Phorum 5.2.23</generator>
        <item>
            <guid>https://www.wxforum.info/read.php?27162,164128,564282#msg-564282</guid>
            <title>Re: Media Queries</title>
            <link>https://www.wxforum.info/read.php?27162,164128,564282#msg-564282</link>
            <description><![CDATA[ I created a demo that accomplished this. I&#039;ll try to explain it. Here&#039;s what I did--<br />
<br />
1. Open up the page (or template) you need to know the width of.<br />
2. Right click the page&#039;s background and click &quot;Description&quot;.<br />
3. In &quot;Advanced&quot;, under the &quot;HTML code added to the page header&quot;, paste this code (delete the extra spaces I added at &quot;&lt; script&quot; and &quot;&lt; /script&quot;):<br />
<br />
<pre class="bbcode">
&lt; script src=&quot;[<a href="http://code.jquery.com/jquery-1.9.1.js&quot;&gt;&lt"  rel="nofollow">code.jquery.com</a>]; /script&gt;
&lt; script src=&quot;[<a href="http://code.jquery.com/ui/1.10.3/jquery-ui.js&quot;&gt;&lt"  rel="nofollow">code.jquery.com</a>]; /script&gt;</pre>
<br />
<br />
4. Click &quot;Validate&quot; on this dialog.<br />
5. Create a text box (edit) control.<br />
6. Right click the control and open the &quot;Description&quot;.<br />
7. You can give it any name (i.e. EDT_ResizeDetect), but you must set the &quot;Caption&quot; to:<br />
<br />
Window Resize Event<br />
<br />
8. Click &quot;Validate&quot; and close this dialog.<br />
9. Right click the page&#039;s background and choose &quot;Code&quot;.<br />
10. Inside the code block for &quot;Load (onload) of PAGE_....&quot;, paste this code:<br />
<br />
<pre class="bbcode">
jQuery(function() {
	
	// Define
	var resizeTimeout = null;
	
	// Detect Resize Event
	jQuery(window).resize(function () {
		
		// Clear Previous Timer
		window.clearTimeout(resizeTimeout);
		
		// Set New Timer
		window.setTimeout(function () {
			
			// Trigger Event
			jQuery(&quot;td:contains(&#039;Window Resize Event&#039;)&quot;).parents(&quot;tr&quot;).find(&quot;input&quot;).val(jQuery(window).width()).trigger(&quot;change&quot;);
			
		}, 350);
		
	});

})</pre>
<br />
<br />
11. Notice in that JavaScript above, the phrase &quot;Window Resize Event&quot;. This is what link&#039;s this code to your control.<br />
<br />
That should be it! Run the page and resize it. The value of your text box should reflect the window&#039;s width in pixels.<br />
<br />
The uses jQuery (which we applied in Step #3). While it&#039;s not necessary to use jQuery to achieve your goal, it simplifies the JavaScript and it&#039;s required to use my sample code.<br />
<br />
Let me know if you experience any issues!]]></description>
            <dc:creator>Andrew Strubhar</dc:creator>
            <category>WebDev Solutions</category>
            <pubDate>Tue, 24 Nov 2015 18:06:06 +0100</pubDate>
        </item>
        <item>
            <guid>https://www.wxforum.info/read.php?27162,164128,164128#msg-164128</guid>
            <title>Media Queries</title>
            <link>https://www.wxforum.info/read.php?27162,164128,164128#msg-164128</link>
            <description><![CDATA[ Hi,<br />
<br />
First off, I am a novice at programming but have a good grip on Webdev so far. I am trying build a &#039;responsive website&#039;, but I am struggling to detect the browser width.<br />
<br />
Fabrice Harari was kind enough to give me his js code:<br />
<br />
function JSGetBrowserWidth()<br />
{<br />
	// return document.body.clientWidth;<br />
	var w=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;<br />
	return w<br />
}<br />
<br />
Not knowing how to code/handle js. I have pasted the code in my home page&#039;s browser code (which is flipped to JS : blue). After this I have no idea what to do....<br />
<br />
Can anyone help me detect a browser&#039;s width so that I can adjust my content depending on the device that is being used?<br />
<br />
Webdev 7-79p<br />
Webdev Dynamic Site<br />
Target Platform: Any<br />
<br />
Thanks in advance to all the pro Webdevers!<br />
NH]]></description>
            <dc:creator>NH</dc:creator>
            <category>WebDev Solutions</category>
            <pubDate>Thu, 27 Jun 2013 17:23:48 +0200</pubDate>
        </item>
    </channel>
</rss>
