Discuss TV Forums - Find jobs - Kamala Harris - Debt Consolidation - Funbrain

PDA

View Full Version : popup window script won't work with a space in the window name.


wolfestone
Feb 16th 2009, 3:24 pm
I'm using the following script, and it's working fine except when my aWinName (the new window's title bar text) has a space in it. I've tried using %20, and also   but both of these cause the window to not appear. If I use a single word for the window title it works fine.

I'd really appreciate it if anyone can tell me either a workaround, or how to modify the script so it'll work with a space in the aWinName parameter.

here's the code:

function f_open_window_max( aURL, aWinName )
{
var wOpen;
var sOptions;

sOptions = 'status=yes,menubar=yes,scrollbars=yes,resizable=yes,toolbar=yes';
sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
sOptions = sOptions + ',height=' + (screen.availHeight - 122).toString();
sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

wOpen = window.open( '', aWinName, sOptions );
wOpen.location = aURL;
wOpen.focus();
wOpen.moveTo( 0, 0 );
wOpen.resizeTo( screen.availWidth, screen.availHeight );
return wOpen;
}


And here's how I'm calling it from my html - the space between Page and One is what stops it working:

<a href="#"><img src="images/myImage" width="200" border="0"
onclick="f_open('pages/page.htm','Page One')" /></a>

dilute
Feb 16th 2009, 3:38 pm
the window name is designed for accessing the window, not setting the title text.

Use:

function f_open_window_max( aURL, aWinName, aTitleText)

then after: wOpen.location = aURL;
put: wOpen.document.title = aTitleText;

if that doesn't work try wOpen.title without the "document" part.

Then call it with onclick="f_open('pages/page.htm','pageone', 'Page One')"

wolfestone
Feb 17th 2009, 4:33 am
awesome, thanks very much!

dilute
Feb 17th 2009, 5:30 am
Rep me. Click the http://forums.digitalpoint.com/images/buttons/reputation.gif