can anyone help me..
this is work in firefox but not working in IE
document.getElementById(Field_id).focus()
Thanks in advance if anyone can solve this.
can anyone help me..
this is work in firefox but not working in IE
document.getElementById(Field_id).focus()
Thanks in advance if anyone can solve this.
that is the correct syntax so long as your page is set up similar to
Code:<body> <div id="Field_id">something that you want focused</div> </body>
you do need to be careful that you have the case correct, although since it works fine in Firefox chances are it is correct....
there isn't a bug in IE that I know of at this time, however if you were to give us more of your code we specifics we would be able to help you.
If you are posting code USE [code] tags
Last edited by djr33; 12-06-2007 at 07:06 PM. Reason: spelling
<div>s cannot receive focus.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Focus places the cursor into an element (text fields), highlights a dropdown menu or otherwise activates an input item in a form. I don't believe any other element on a page can receive focus at all, as it would do nothing. Even if there were a way to theoretically focus it, it would be entirely worthless.
Now, as a sidenote, the other elements that can receive focus are different windows, like mypopup.focus(), or (I guess) frames/iframes.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Links too. Generally speaking, any element with which the user can interact can receive focus.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Well, any element that can interact with a user through standard html. Javascript can make any element interact, but that doesn't mean it'll focus.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
True.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
And getting back to the original question, this may be the problem-- how does one focus a particular popup div rather than another (ie setting the z-indexes). That becomes a complex problem.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
The original question was on how to focus on what appears to be a field by its id. For that, the javascript focus() method would be fine. And, if it is a form field (even if it isn't in a form), it should work just as well in IE as in FF. However, the visual cue(s) that the focus has shifted to the field could well differ between these two browsers, though perhaps not. The method of actually accessing the field (including all supporting and incidental code) may be at issue, in fact that is probably the problem if this is a form field element.
If you need more help, zea726:
Please post a link to the page on your site that contains the problematic code so we can check it out.
Last edited by jscheuer1; 12-07-2007 at 12:00 PM. Reason: add info
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Thank you guys....
I think i should have ask it in slightly descriptive way....
Actually i am creating a cv editing panel....
So i have a page called "cv_container.php" where i have a form which have table.in different td of this table i am calling some pages using ajax....
Now in the main page(that i m calling) which also contains form (so i have two forms actually) have multiple text field... the task is to when u mouse over any field it will change its color and mouse out to its original color.but while u click it should focus. for this i have returned a html tag with same id as the html and trying to focus it, working on ff but not in ie. some html code and the 3 functions of javascript is given below
html
HTML Code:<td bgcolor="#CAE7F1"> <div id="show_st1_father_name"><input id="st1_father_name" value="<? echo $edit_value[father_name]; ?>" name="st1_father_name" type="text" size="48" onFocus="chekval_pinfo('st1_father_name');this.className='tdinputtext';" onBlur="showFatherName();" class="tdinputtext" style="background-color:#CAE7F1; border: none" onmouseover="zea('st1_father_name');" onmouseout="z('st1_father_name','#CAE7F1')" onclick="load_which('st1_father_name','hid_st1_father_name','show_st1_father_name','showFatherName()','#CAE7F1','48')"> </div> </td>
javascript functions
function zea(id){
//onmouseover
document.getElementById(id).className="tdinputtext";
document.getElementById(id).style.backgroundColor = "#FFFFCC";
document.getElementById(id).className="tdinputtext";
//var html="<input type='text' id='st1_n' value='"+a+"' size='48' style='border:none; background-color:#FFFFCC' class='tdinputtext' onMouseOut='zea1(1,""+a+"",""+b+"",""+div_id+"")' onclick='zea1(2,""+a+"",""+b+"",""+div_id+"")'>";
//document.getElementById(div_id).innerHTML=html;
}
function z(id,color){
//onmouse out
document.getElementById(id).className="tdinputtext";
document.getElementById(id).style.backgroundColor = color;
}
function load_which(n1,h_id1,div_id1,check_func,color,f_size){
//onclick
var val=document.getElementById(h_id1).value;
if(n1=="st1_personal_text"){
textare(h_id1,div_id1);
}
else if(n1=="st1_currentsalary" || n1=="st1_expectedsalary"){
var v=document.getElementById(n1).value;
var arr = v.split("B");
var html="<input name='"+ n1 +"' id= '"+ n1 +"' value='" + arr[0] + "' type='text' onFocus='chekval_pinfo(""+ n1 +"");this.className=" tdinputtext ";' onBlur='" + check_func + "' size='"+ f_size +"' class='tdinputtext'>";
document.getElementById(div_id1).innerHTML=html;
if(n1=="st1_currentsalary")
document.getElementById("cs").innerHTML=" BDT/month";
else
document.getElementById("es").innerHTML=" BDT/month";
document.getElementById(n1).focus();
}
else{
var html="<input name='"+ n1 +"' id= '"+ n1 +"' value='" + val + "' type='text' onFocus='chekval_pinfo(""+ n1 +"");this.className=" tdinputtext ";' onBlur='" + check_func + "' size='"+ f_size +"' class='tdinputtext'>";
document.getElementById(div_id1).innerHTML=html;
//document.forms["personal_info"].elements[n1].focus();
document.getElementById(n1).focus();
}
if(n1=="name"){
name=1;
}
if(n1=="age"){
age=1;
}
}
Thanks guys once again
Last edited by zea726; 12-07-2007 at 02:54 PM. Reason: have some smiles which i dont want
Bookmarks