Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
| Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 29th, 2006, 12:55 AM
Registered User
 
Join Date: Sep 2006
Location: Islamabad, Islamabad, Pakistan.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to usman_iftikhar
Default Javascript & Safari (On MAC OS)

I have written a javascript code for scrolling table row by row using Arrow Keys (up & down) using onKeyDown event. This code works fine in IE (on Windows Server 2003) but it didn't work in safari (MAC OS). In Safari when i press down or up key it generates keycode twice e.g. keycode=40 for down key and keycode=38 for up key. I want the exact keycodes for arrow keys, enter key, and space bar for Safari browser. Anyone has idea about problem???

usman
  #2 (permalink)  
Old September 29th, 2006, 10:08 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Key codes are the same on the Mac as they are on Windows. It's difficult to give you an answer without seeing the script. My guess is it is something else causing your script to fail.

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
  #3 (permalink)  
Old October 1st, 2006, 11:01 PM
Registered User
 
Join Date: Sep 2006
Location: Islamabad, Islamabad, Pakistan.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to usman_iftikhar
Default

i am sending u the script for scrolling the table. it works fine in windows but not on MAC. might be u will get hint now
-------------------------script
I have generated a dynamic table in for loop

//in for loop
<tr class="<%=cls%>" id="row<%=rowNum%>" onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'" onKeyDown="checkUpDown(event,<%=rowNum%>);">
                                    <td width="30%" nowrap align="left" valign="middle" >
                                        <%=code%>
                                    </td>
                                    <td width="70%" nowrap align="left" valign="middle" >
                                        <%=desc%>
                                    </td>
                                </tr>
////////////////////////////////////////////////////////////////////////////////////////
function checkUpDown(ev,rowNum)
{



var kc = getKeyCode(ev);


if (kc==40) //DownScrolling
{
DownScrollNew(rowNum)
return
}


if (kc==38)
{
UpScrollNew(rowNum,rec); //up scrolling
return
}
///////////////////////////////function for down scrolling

function DownScrollNew(rowNum)
{

prevRowSelection(rowNum); // this function is used to change CSS class of previous row this function is defined below
rowNum=rowNum+1;
var nextRow=getObject("row" + rowNum);

if (nextRow!=null)
{
nextRow.cells[0].focus();
nextRow.className="tableRowSelect" //row color becomes blue
prevSelectedRow=rowNum;
}

if (nextRow==null)
{
rowNum=rowNum-1;
prevRowSelection(rowNum);
rowNum=-1;
nextRow=getObject("row" + 0);
nextRow.className="tableRowSelect"
nextRow.cells[0].focus();
prevSelectedRow=0;

}

}
///////////////////////////////////function for upScrolling
function UpScrollNew(rowNum)
{

prevRowSelection(rowNum);
rowNum=rowNum - 1;
var prevRow=getObject("row" + rowNum);

if (prevRow!=null)
{

    prevRow.cells[0].focus();
    prevRow.className="tableRowSelect"
    prevSelectedRow=rowNum;
}

if (prevRow==null)
{

    rowNum=0;
    prevRowSelection(rowNum);
    rowNum=rec;
    prevRow=getObject("row" + lastRowIndex); //suppose lastRowIndex=9 (i.e. Total 10 Rows in table)
    prevRow.cells[0].focus();
    prevRow.className="tableRowSelect"
    prevSelectedRow=rec;

}
}
//////////////////////////////prevRowSelection
function prevRowSelection(rowNum)
{
 var cls = "tableRowOdd"; // it converts row color to white
 var prevRow=getObject("row" + rowNum);
 if (prevRow !=null)
{
        if (rowNum % 2 == 0)
        {
        cls = "tableRowEven"; //it converts row color to pink
        prevRow.className=cls;
        }
        else
        {
        prevRow.className=cls
        }
     }
}
/////////////////////////////////////////


usman


Similar Threads
Thread Thread Starter Forum Replies Last Post
text editor for mac os 9.2 starfrog CSS Cascading Style Sheets 4 February 1st, 2018 06:47 AM
safari for mac not refreshing content of page. toshi Javascript 0 December 19th, 2007 10:30 AM
div scrolling not working in safari mac toshi CSS Cascading Style Sheets 1 December 1st, 2007 04:48 AM
include problems on Mac OS clem_c_rock Beginning PHP 4 May 19th, 2004 11:04 AM
JRun4 for Mac OS + Mac OS X's Java 1.4.1 elbicho J2EE 0 June 27th, 2003 12:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.