2010/03/08

解決jquery.blockUI v2 在IE6會出現安全性警告的問題

以下針對jquery.blockUI v2.16的版本做修改。

因為jquery.blockUI在MSIE的處理上, 為了避免下拉選單的破洞問題, 使用了iframe做層級的處理
但因為ie6針對iframe的src若沒有設定值的話, 會有安全性的警告跑出來, 很惱人

以下為修改方式:

1. 做一個空白的頁面, 命名為blank.html, 放在根目錄
2. 修改jquery.blockUI.js 第187行, 把iframe的src屬性, 由src='about:blank' 改成 src='/blank.html'

如此一來, 在ie6就不會再有安全性警告跑出來了

參考:
http://malsup.com/jquery/block/#
http://support.microsoft.com/kb/261188/zh-tw

2009/07/25

2009/07/24

解決ie6,ie7的select option disabled沒有作用的問題 Select, Option, Disabled And The JavaScript Solution In IE7, IE6, IE5.5

解決方案:
http://www.lattimore.id.au/2005/07/01/select-option-disabled-and-the-javascript-solution/

下載js檔, 並include到頁面即可, 作法是把頁面的select element找出來, 判斷有disabled的option就變顏色且不可選擇
http://www.lattimore.id.au/files/examples/select-option-disabled-emulation.js

因為只有在ie7以下的版本有問題, 其他瀏覽器沒問題, 所以我改寫了一下
if (navigator.appVersion.indexOf("MSIE 5.5") >= 0 || navigator.appVersion.indexOf("MSIE 6.0") >= 0 || navigator.appVersion.indexOf("MSIE 7.0") >= 0) {
window.onload = ReloadSelectElement;
}
function ReloadSelectElement() {
if (document.getElementsByTagName) {
var s = document.getElementsByTagName("select");
if (s.length > 0) {
window.select_current = new Array();
for (var i = 0, select; select = s[i]; i++) {
select.onfocus = function() { window.select_current[this.id] = this.selectedIndex; }
select.onchange = function() { restore(this); }
emulate(select);
}
}
}
}
function restore(e) {
if (e.options[e.selectedIndex].disabled) {
e.selectedIndex = window.select_current[e.id];
}
}
function emulate(e) {
for (var i = 0, option; option = e.options[i]; i++) {
if (option.disabled) {
option.style.color = "graytext";
}
else {
option.style.color = "menutext";
}
}
}

軟體工程的重要的指標