發表文章

目前顯示的是有「跨瀏覽器支援」標籤的文章

iframe在非IE瀏覽器指定Src及動態改變高度的問題

在IE瀏覽器內想要改變iframe頁框的Src值,只需要直接指定 iframe.src='XXXX.htm'; ,如此就可以改變連結的路徑,但是其他瀏覽器可就不吃這一套了(至少我試了Firefox,Chrome都是如此)。 1. 在其它瀏覽器內iframe若要指定src有反應,必須要補齊所需要的網頁元素。如 html,head,body ...... 2. 另外若要動態指定iframe的高度IE瀏覽器也與其它瀏覽器有所不同 IE  →  iframe.Document.body.scrollHeight Other →  iframe.contentDocument.body.offsetHeight

showModalDialog 子視窗搖控父視窗在IE以外流覽器失效

在IE我們在使用showModalDialog打開一個畫面後,如果要使用子視窗來改變父視窗的值只需要使用 window.dialogArguments.document.getElementById("父視窗物件ID").value = "想改變的值"; 但是我在FireFox使用此方法發現無效,原來除了IE以外的瀏覽器,大部分的瀏覽器不是使用此方法來改變父視窗的值而是採用下面此方法來達成 if (window.dialogArguments != null) //IE使用 var querytype = window.dialogArguments.document.getElementById("父視窗物件ID"); else //其他如 Friefox,Chrome var querytype = opener.window.document.getElementById("父視窗物件ID"); querytype.value = 'Return Value'; window.close();

showModalDialog 跳出後背景灰階的語法

圖片
function GridView_OpenDialog2(url, widthpx, heightpx, imgurl) { var dialogcenter = ";dialogTop:" + ((window.screen.height / 2) - (heightpx.replace("px", "") / 2)) + " ; dialogLeft:" + ((window.screen.width / 2) - (widthpx.replace("px", "") / 2)) + ";"; if (imgurl) { var mask = document.createElement("DIV"); mask.id = "GridView_mask"; var style = ""; style += "background-color:white;"; style += "width:100%; height:100%;"; style += "position:fixed; top:0; left:0; zindex:1000;"; style += "filter:alpha(opacity=70); opacity:0.7; zoom:1;-moz-opacity:0.7;"; mask.style.cssText = style; //=======下面這些只有IE支援不建議這樣使用 //mask.style.position = "fixed"; //mask.style.top = 0; //mask.style.left = 0; //mask.style.width = "100%"; ...

Firefox內使用style.display="block"無作用的問題

IE顯示隱藏區的Javascript語法為document.all.object.style.display="block"但此用法在Firefox並不適用 function exeInsert() { //Firefox使用空白顯示有別於IE的block document.getElementById("divInsert").style.display=""; document.getElementById("divEdit").style.display="none"; document.getElementById("txtInsert").value = ""; document.getElementById("txtSearch").value = ""; //document.all.divInsert.style.display="block"; //document.all.divEdit.style.display="none"; }

Firefox使用showModalDialog回傳時觸發事件

此範例因為使用ASP.NET的MastPage的關係,所以導致按鈕的ID與平常不一樣,須特別注意。 主頁面 window.showModalDialog('ContentInfo.aspx?class=edit&sno='+ e ,self,feature); //執行回傳按鈕事件 if(document.all) { //Name document.getElementById("ctl00$ContentPlaceHolder1$btnReload").click(); } else { //Firefox 專用 var evt = document.createEvent("MouseEvents"); evt.initEvent("click", true, true); document.getElementById("ctl00_ContentPlaceHolder1_btnReload").dispatchEvent(evt); } 主頁面呼叫的按鈕事件 <asp:Button ID="btnReload" runat="server" Text="" onclick="btnReload_Click" />