View Full Version : Using Eric's popup window from a button

06-30-2008, 06:37 PM
Hi there,
I have been using Eric's pop-up window script from a button within a form with great success... but recently discovered that my routine doesn't work in Internet Explorer 7 because Microsoft do not implement the 'getAttribute' function in accordance with w3 standards.

The routine that I have is:-

<input name='button1' type='button' href ="2coupleweekend/table2coupleweekend2.html" title="2 Couple Weekend League - Table" onClick="NewWindow(this.getAttribute('href'),this.getAttribute('title'),'500','350','no','center');return false" value=" View League Table ">

Can anyone help point me in the right direction to adjust the code so that clicking the button opens a pop-up window centrally in the screen?

Thanks in anticipation,


06-30-2008, 07:34 PM
Well, have just tried to go back to an ordinary link to open the pop-up and again it works in Firefox - but not IE7!

Can anyone advise why this will not work in IE7?

The Script is Eric's standard:-

<script language="javascript" type="text/javascript">
Author: Eric King
Url: http://redrival.com/eak/index.shtml
This script is free to use as long as this info is left in
Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,re sizable=no';
// -->

and the calling code is:-

<a href="2coupleweekend/table2coupleweekend1.html" title="2 Couple Weekend Division 1 - Table" onclick="NewWindow(this.href,this.title,'500','350','no','center');return false" onfocus="this.blur()">View League Table</a>

thanks in anticipation,


06-30-2008, 09:55 PM
Hi again,

Well I have it working with the following:-

<input name='button1' type='button' href ="2coupleweekend/table2coupleweekend2.html" title="2 Couple Weekend League - Table" onClick="NewWindow(this.getAttribute('href'),this.getAttribute('name'),'500','350','no','center');return false" onfocus='this.blur()' value=" View League Table ">

I changed 'this.getAttribute('title')' to 'this.getAttribute('name')' and it works... but why?



07-01-2008, 02:31 AM
You are playing with fire because href is not a valid attribute of an input tag. And getAttribute isn't always the best way to get an attribute. But it appears that browsers will forgive that. Here is what I would recommend (based upon your first post):

<input name='button1' type='button'
title="2 Couple Weekend League - Table"
'The_2_Couple_Weekend_League_-_Table','500','350','no','center');return false;"
value=" View League Table ">

The real problem you were having though appears to be IE's adherence to the standard that doesn't allow a window name (the second field in the NewWindow function call) to contain spaces or to begin with a number. Hence this.name works, since the name is 'button1', but this.title didn't because the title was '2 Couple Weekend League - Table'.