<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dwcourse.com &#187; behaviors</title>
	<atom:link href="http://www.dwcourse.com/dreamweaver/tag/behaviors/feed" rel="self" type="application/rss+xml" />
	<link>http://www.dwcourse.com</link>
	<description>Adobe Dreamweaver Tips, Tricks and Tutorials</description>
	<lastBuildDate>Fri, 23 Jul 2010 09:26:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Open Browser Window and Bring to Front</title>
		<link>http://www.dwcourse.com/dreamweaver/open-browser-window-in-front.php</link>
		<comments>http://www.dwcourse.com/dreamweaver/open-browser-window-in-front.php#comments</comments>
		<pubDate>Thu, 23 Jul 2009 18:33:29 +0000</pubDate>
		<dc:creator>jcook</dc:creator>
				<category><![CDATA[Tip of the Day]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[behaviors]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[open browser window]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://dwcourse.com/?p=346</guid>
		<description><![CDATA[One Dreamweaver feature that been around for a while is the Open Browser Window (OBW for short) behavior. Described simply, the behavior is a JavaScript that opens a page in a new window while at the same time specifying the size, attributes (scrollbars, resize handles. etc.) and name of the window. Once a window is [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>One Dreamweaver feature that been around for a while is the Open Browser Window (OBW for short) behavior. Described simply, the behavior is a JavaScript that  opens a page in a new window while at the same time specifying the size, attributes (scrollbars, resize handles. etc.) and name of the  window. Once a window is created and named in this manner it can be targeted by additional instances of the OBW behavior or even regular links.</p>
<p>The problem is that &#8211; <strong>in Explorer and Firefox</strong> &#8211; when you target a preexisting window with the OBW behavior, the new page opens  but the targeted window does not come to the front (technically, the targeted window does not gain focus). That means that your new page opens but the user doesn&#8217;t see it because it&#8217;s hidden. Probably not the solution you were looking for.<span id="more-346"></span></p>
<p><script type="text/javascript">// <![CDATA[
 function DWC_openBrWindow(theURL,winName,features) { 
newwindow=window.open(theURL,winName,features); 
if (window.focus) {newwindow.focus()} 
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// ]]&gt;</script></p>
<p>Here&#8217;s an example created using DW&#8217;s built-in OBW behavior. If you&#8217;re using Explorer of Firefox (Safari users don&#8217;t have this problem), click on the first link below and a new window &#8211; which I&#8217;m naming &#8220;popup&#8221; &#8211; will open. Make sure that &#8220;popup is positioned over this window, leave it open, return to this page and click on the second link.</p>
<p align="center"><a onclick="MM_openBrWindow('/test-pages/page1.html','popup','width=200,height=200');return false;" href="#">Open Page 1</a> then come back and <a onclick="MM_openBrWindow('/test-pages/page2.html','popup','width=200,height=200');return false;" href="#">Open Page 2</a><a href="#"></a></p>
<p>The second link opens a new page in the existing &#8220;popup&#8217; window but you won&#8217;t see it because it&#8217;s hidden behind this window. To verify that the new page opened, minimize (<strong>But don&#8217;t close!</strong>) this window. I&#8217;d hate to lose you just when things are getting interesting! Once you&#8217;re curiosity is satisfied, leave the pop-up window open and maximize this window.</p>
<p>What you&#8217;d really like to happen is what happens when you click on the link below.</p>
<p align="center"><a onclick="DWC_openBrWindow('/test-pages/page3.html','popup','width=200,height=200');return false;" href="#">Open Page 3</a></p>
<p>Notice that the new page opens in the existing &#8220;popup&#8221; window AND the window comes to the front. Fortunately, all it takes to work this magic is the substitution of a few lines of code in the JavaScript function  <strong>MM_openBrWindow</strong> that Dreamweaver creates to handle the OBW behavior. Here&#8217;s all you need to do:</p>
<ol>
<li>In Dreamweaver, using the Behaviors palette,  attach the OPB behavior to an object in your page.</li>
<li>Switch to either the Code or Split view.</li>
<li>Near the top of the code of your page, somewhere between the opening head and closing head tags (&lt;head&gt; and &lt;/head&gt; respectively) locate the following three lines of code which define the <strong>MM_openBrWindow</strong> function:<br />
<code>function MM_openBrWindow(theURL,winName,features) { //v2.0<br />
window.open(theURL,winName,features);<br />
}</code></li>
<li>Copy the code below  and use it to replace the code you located in step 3 above.<br />
<code>function MM_openBrWindow(theURL,winName,features) {<br />
newwindow=window.open(theURL,winName,features);<br />
if (window.focus) {newwindow.focus()}<br />
}</code></li>
<li>That&#8217;s it! Now whenever you use the Open Browser Window Behavior in your page you can rest assured the window will pop to the front and be visible. Just remember, since DW inserts the JavaScript in the page (and that&#8217;s where we customized it), you&#8217;ll need to make this change on every page where you use the OBW behavior.</li>
</ol>
<p><em><strong>Note:</strong> When using the <strong>links relative to site root</strong> option, this customized script will fail  using DW&#8217;s Preview in Browser feature. However it will function properly when uploaded to your web server. Using <strong>links relative to document</strong> avoids the problem all together.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dwcourse.com/dreamweaver/open-browser-window-in-front.php/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
