SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: IE 6.x problem

  1. #1
    SitePoint Enthusiast Roj2002's Avatar
    Join Date
    Jan 2002
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question IE 6.x problem

    Hi,

    I'm having a javascript problem with IE 6.x. Here is part of a script:

    Test = window.open(strZiel, strName, 'width='+intWidth+',height=145');
    if (document.all) {
    var ClickX = window.event.x;
    var ClickY = window.event.y;
    var Distance;
    if (navigator.appVersion.indexOf("MSIE 5")>0 )
    {
    Distance = screen.width - (ClickX+window.screenLeft+250);
    if (Distance > 0) {
    Test.moveTo(ClickX+window.screenLeft+5, ClickY+window.screenTop-50);
    }else{
    Test.moveTo(ClickX+window.screenLeft-250, ClickY+window.screenTop-50);
    }
    }

    It works fine with Netscape 6.x and Ie.5.x, but I get an erreo with IE6.0!

    It seems "window.event.x" and "window.event.y" is unknown to IE 6.x...

    Michael

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Roj,

    with the code you posted I get an error in NN6.1 -- essentially the same as IE 6, and probably IE 4+ -- window.event has no properties.... Where are you getting the (presumably) 'click' from? -- more code or a url if you please.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Enthusiast Roj2002's Avatar
    Join Date
    Jan 2002
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Vincent,

    okay lets try it again, I can't post an URL but here is a peace of code that should do it:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>

    <script language="JavaScript" type="text/javascript">
    function OpenWindow(strZiel, strName, intWidth) {
    Test = window.open(strZiel, strName, 'width='+intWidth+',height=145');
    if (document.all) {
    var ClickX = window.event.x;
    var ClickY = window.event.y;
    var Distance;
    if (navigator.appVersion.indexOf("MSIE 5")>0 )
    {
    Distance = screen.width - (ClickX+window.screenLeft+250);
    if (Distance > 0) {
    Test.moveTo(ClickX+window.screenLeft+5, ClickY+window.screenTop-50);
    }else{
    Test.moveTo(ClickX+window.screenLeft-250, ClickY+window.screenTop-50);
    }
    }
    }
    }
    </script>
    </head>

    <body>
    <form name="formular">
    <table align="center" border="0" cellpadding="0" cellspacing="0" width="50%">
    <tr>
    <td><br><br><br><br>
    Kursstartbr>
    <input type="text" name="new_kurstart" value="" size="10" maxlength="10">&nbsp;<a href="javascript:OpenWindow('datum.php?ZielFeld=formular.new_kurstart', 'Auswahl1', 135)">Change</a>
    </td>
    </tr>
    <tr>
    <td>
    Kursendebr>
    <input type="text" name="new_kurende" value="" size="10" maxlength="10">&nbsp;<a href="javascript:OpenWindow('datum.php?ZielFeld=formular.new_kurende', 'Auswahl2', 135)">Change</a>
    </td>
    </tr>
    </table>
    </form>


    </body>
    </html>

    So what is (or should happening) is the following: When you click on "Change" a new window is opened (the URL isn't found in this demo), this works fine with all browsers. Now the winbdow should be moved near the position where you clicked on "Change". This works fine in IE 5.x, in IE 6.x I get a java script error, because IE 6.x doesn't seem to know "window.event.x" and "window.event.y". Netscape 6.x moves the window, but not to the right possition and Netscape 4.x doesn't move the window, but isn't producing an error.

    The perfect solution would be a peace of code that works with IE >= 5.0 and Netscape 4.x and 6.x. ;-)

    Roj2002

  4. #4
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    First of all, you are never sending any event, so I still don't see how it worked for IE5. Any rate the following will send your event to the function:

    <input type="text" name="new_kurende" value="" size="10" maxlength="10"> <a href="#" onclick="OpenWindow(url, title, 135, event)">Change</a>

    Your function should then look something like this:

    function OpenWindow(strZiel, strName, intWidth, evt)
    {
    var ClickX = (document.all) ? evt.clientX : evt.x;
    var ClickY = (document.all) ? evt.clientY : evt.y;

    Since IE6 still uses document.all, it will get its numbers from 'clientX/Y'. NN4 and I suspect everyone else (though I'm not certain since I didn't bother looking in a book or an old script) will use 'x/y'

    You may still have a problem with your 'moving' code.
    But, now you've got a start
    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still


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
  •