Results 1 to 4 of 4

Thread: Using Eric's popup window from a button

  1. #1
    Join Date
    Mar 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Using Eric's popup window from a button

    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:-
    HTML Code:
    <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,

    Allan

  2. #2
    Join Date
    Mar 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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:-
    Code:
    <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){
    if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
    if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
    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,resizable=no';
    win=window.open(mypage,myname,settings);}
    // -->
    </script>
    and the calling code is:-
    Code:
    <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,

    Allan

  3. #3
    Join Date
    Mar 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Solved - but why?

    Hi again,

    Well I have it working with the following:-

    Code:
    <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?

    regards,

    Allan

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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):

    Code:
    <input name='button1' type='button' 
    title="2 Couple Weekend League - Table" 
    onclick="NewWindow('2coupleweekend/table2coupleweekend2.html',
    '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'.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •