为什么在这个IE code不工作?另外,按钮应图像按钮,而不是常规的1 [英] How come this code doesnt work in IE? Also the button should be image button and not regular one

查看:107
本文介绍了为什么在这个IE code不工作?另外,按钮应图像按钮,而不是常规的1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这code工作在FF但不是在IE浏览器。

This code works in FF but not in IE .

林难倒为什么clickme按钮仍然在IE无形..
也请更改按钮自定义图像按钮..你在code使用任何随机图像像image.jpg的

Im stumped why the "clickme" button is still invisible in IE.. Also pls change the button to custom image button.. you use any random image like image.JPG in the code

感谢您的帮助。

<html> 
<script language="javascript"> 
var myLink = ""; 
function hideMe() { 
    document.getElementById('btn3').style.visibility='hidden'; 
} 

function setMyAdd() { 
    location.href=myLink; 
} 


function checkForChange() { 

    document.getElementById('btn1').style.visibility='visible'; 
    document.getElementById('btn2').style.visibility='visible'; 

    var buttonSelected=selList.value; 

    // alert("Option Selected is : " + buttonSelected ); 

    if (buttonSelected=="optx") { 
    myLink = "myPage2.html"; 
    document.getElementById('btn1').style.visibility='hidden'; 
    document.getElementById('btn2').style.visibility='visible'; 
    document.getElementById('btn3').style.visibility='visible'; 
    } else { 
    myLink = "myPage1.html"; 
    document.getElementById('btn1').style.visibility='visible'; 
    document.getElementById('btn2').style.visibility='hidden'; 
    document.getElementById('btn3').style.visibility='visible'; 
    } 
} 
</script> 
<body onLoad="hideMe()"> 
<form> 
<select onChange="checkForChange()" id="selList"> 
    <option value="opt1">Option 1</option> 
    <option value="opt2">Option 2</option> 
    <option value="opt3">Option 3</option> 
    <option value="optx">Option X</option> 
</select>  
<BR><br> 
<input type=button value="Option 1,2,3" id="btn1"> 
<BR> 
<input type=button value="Option X" id="btn2"> 
<BR> 
<input type=button value="Click me" id="btn3" onClick="setMyAdd()"> 
</form> 
</body> 
</html>

问题是,可见/隐藏没有工作在IE即当我选择任何选项,我将不会看到第三个按钮点击我即低于codeS不工作

The problem is that visible/hidden are not working in IE i.e. when I select any option, I won't see third button Click me i.e. below codes are not working

    document.getElementById('btn1').style.visibility='hidden'; 
    document.getElementById('btn2').style.visibility='visible'; 
    document.getElementById('btn3').style.visibility='visible'; 

同样是工作在FF。

Same is working in FF.

推荐答案

知名度和显示是不同的东西,因为他们的名字的意思是一样的。两个属性是要用于所有具有显示器或能见度的元素

visibility and display are different things, the same as their names mean. Both attributes are to be used for all the elements which have a display or a visibility.

能见度简单。一个元素可以是可见的('看得见'的价值),隐藏('隐藏'值)。
在表格的元素时,Mozilla还使用了崩溃的价值,但IE浏览器没有。

The visibility is simple. An element can be visible ('visible' value), hidden ('hidden' value). In case of the table's elements, Mozilla uses also the 'collapse' value, but IE does not.

显示器是一个更复杂的属性。该值依赖于要素(行内,块列表....)的显示类型。关于表和表的元素,Mozilla和IE浏览器有不同的看法。莫兹使用DOM值(见 http://www.w3.org/ TR / REC-CSS2 / tables.html#Q2 ),而IE浏览器只是用来为正显示'块'的价值。

The display is a more complex attribute. The values depends on the display type of the element (inline, block, list....). Regarding the table and table's elements, Mozilla and IE have different visions. Moz uses the DOM values (see http://www.w3.org/TR/REC-CSS2/tables.html#q2 ) while IE simply uses 'block' value for as positive display.

要避免所有这些错综复杂的跨浏览器的解决方案,在能见度的情况下,迈用对可见的/隐藏,并在画面中,您可以使用双''/'无'的情况下(这意味着你可以使用,而不是'块'

To avoid an intricate cross-browser solution for all these, in case of visibility, you mai use the pair 'visible'/'hidden', and in case of display you may use the pair ''/'none' (that means you may use a blank value instead of 'block'

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript" > 
function showhide(att,val){
document.getElementById("hid").style[att]=val;
}
</script>
</head>
<body>
<form name="myform">
<table width="100%"  border="4" cellpadding="2" cellspacing="2">
    <tr>
        <td  class="tableheader" colspan="9">TS </td>
    </tr>
     <tbody id="hid">
    <tr>
        <td width="17%" class="labeltext">Tran Code</td>
        <td width="1%"  class="blanktext">:</td>
        <td colspan="4" class="blanktext">Name</td>
    </tr>
    <tr>
        <td width="17%" class="labeltext">Product Type</td>
        <td width="1%"  class="blanktext">:</td>
        <td colspan="4" class="blanktext">
        </td>
    </tr>
     </tbody>
    <tr>
       <td>
       </td>
    </tr>

</table>
Display
 <br>
<input type="button" onclick="showhide('display','')" value="Display on">
<input type="button" onclick="showhide('display','none')" value="Display off">
<br>
<br>
Visibility
<br>
<input type="button" onclick="showhide('visibility','visible')" value="Visibility on">
<input type="button" onclick="showhide('visibility','hidden')" value="Visibility off">
</form>
</body>
</html>

这code将在IE和FF两地工作...

This code will work in IE and FF both places...

这篇关于为什么在这个IE code不工作?另外,按钮应图像按钮,而不是常规的1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆