Javascript Frustration – Spaces in Window Names

It's the little things that drive us to an early grave. Was working on a page this morning, it had a Javascript call along the lines of:

function openPage(myPage,myTitle,settings) {

win = window.open(myPage,myTitle, settings);

}

Then I had a link on the page:

<a href="javascript:openPage('demo.asp','document view','width=600,height=400,scrollbars=yes');">Click This</a>

Works in FireFox. Get error in Internet Explorer.

Of course took me 30 minutes of messing around to realise the problem – the space in the window title. Has to be 'documentview' with no space. You'd think I'd know better after all these years, but it's the little typos that cause us the most grief most often I reckon. FireFox is more adaptable and figured out that a space didn't make the blindest difference and let it through to the keeper. IE, of course, gave a useless indefinite error and wouldn't work.

1 thought on “Javascript Frustration – Spaces in Window Names

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s