www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] focus in firefox trouble

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Posts
    54

    resolved [RESOLVED] focus in firefox trouble

    Hi!

    I'm trying to use an onclick event on a link to make the page scroll down to a <td> which is labeled with an id.
    HTML Code:
    <td id="<?php echo $objectnr; ?>..........</td>
    To do this I am using this on the link:
    Code:
    <td onclick="javascript:document.getElementById(\''.$objectnr.'\').focus()" width="15%" align="left" bgcolor="'.$bg_color.'">
    		<a onmouseover="javascript:this.style.cursor=\'hand\'"> <u><font color="#000000">'.$row["objectnr"].'</font></u></a></td>
    As you can see I also want the cursor to change to a hand when being over the objectnumber. Dont worry about the php you see in there, it is taken care of since the whole thing is within a php echo.
    Before I used to link down with a normal <a href="#q1">Link</a>, but that did not work in Firefox, so now I tried the above code...

    The problem:
    This works perfectly in IE but it just wont work with Firefox!
    What do I do wrong?

  2. #2
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    At a first glance:
    Code:
    <td onclick="javascript:document.getElementById(\''.$objectnr.'\').focus()" width="15&#37;" align="left" bgcolor="'.$bg_color.'">
    		<a onmouseover="javascript:this.style.cursor=\'hand\'"> <u><font color="#000000">'.$row["objectnr"].'</font></u></a></td>
    The syntax is :

    <element onevent="function()">
    or
    <element onevent="statements">

    And the CSS correct attribute for the cursor is "pointer", not "hand"

  3. #3
    Join Date
    Mar 2008
    Posts
    54

    pointer works, but not the focus

    Hi!

    Now the cursor changer works fine in firefox, thanks, but I would like the focus thing to work too.

    Code this far:
    Code:
    echo '<td onclick="javascript:document.getElementById(\''.$objectnr.'\').focus()" width="15&#37;" align="left" bgcolor="'.$bg_color.'">
    		
    <a onmouseover="javascript:this.style.cursor=\'pointer\'"><u><font color="#000000">'.$row["objectnr"].'</font></u></a></td>';
    Remainder: The cursor works in both firefox and IE, but the focus isn't working, what do I do?

  4. #4
    Join Date
    May 2008
    Posts
    52
    Just shooting in the dark here, but maybe the element is being focused, but not brought into view. Have you tried using scrollIntoView?

    http://msdn.microsoft.com/en-us/libr...30(VS.85).aspx

  5. #5
    Join Date
    Mar 2008
    Posts
    54

    resolved solved

    Thank you! Your shot into the dark worked and the best way to fix the code to work in both IE and FF is as following:

    Code:
    		echo '<td onclick="javascript:document.getElementById(\''.$objectnr.'\').scrollIntoView(true)" width="15%" align="left" bgcolor="'.$bg_color.'">
    		<a onmouseover="javascript:this.style.cursor=\'pointer\'"><u><font color="#000000">'.$row["objectnr"].'</font></u></a></td>';
    *note that the echo is part of php, and therefore you have variables like $objectnr in the code, and also slashes (\) before the ' symbol.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles