簡體   English   中英

使用適用於所有瀏覽器的jQuery或Javascript創建彈出框

[英]Creating a popup box using jQuery or Javascript that works for all browsers

我有類似以下的代碼,可在chrome瀏覽器中正確顯示彈出消息,但是我已經在其他瀏覽器(如Firefox和Edge)上對其進行了測試,但這沒有用,只是在末尾裝了一個看起來很奇怪的框頁面...代碼是:

var iframe = document.createElement("IFRAME");
        iframe.setAttribute("src", 'data:text/plain,');
        document.documentElement.appendChild(iframe);
        if(window.frames[0].window.confirm("Are you sure you want to change brand state? Note: Changing brand state from Preview to Live will erase all data related to that brand.")) {
            $.post("/brand/updateBrandState", {
                'brandId': $(this).val(),
                "brandState": $(this).find("option:selected").text()
            }, function (data) {
                if (data == "ok") {
                    window.location.reload(true);
                }else if(data=="empty") {
                    alert("Cannot change state from Live to Preview");
                    window.location.reload(true);
                }else if(data=="live") {
                    alert("Brand is now live!");
                }
            });

有人可以幫助我使其在其他瀏覽器上正常工作嗎?

謝謝 !!

編輯:

現在即時通訊使用此html:

 <div id="dialog" title="Basic dialog"> 
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p> 
</div>

對於彈出框,請使用jQuery Dialog 易於使用,並且受所有支持jquery的瀏覽器支持。

演示

$("#myDialog").dialog({
    resizable: false,
    height: 140,
    modal: true,
    buttons: [
        {
            text: "Yes",
            click: function () {
                $(this).dialog("close");
                //Do some Job
            },
        },
        {
            text: "No",
            click: function () {
                $(this).dialog("close");
            },
        }

    ],
    open: function (event, ui) {
    //add some functionality or styling if you want
    },
    //same for close,drag,dragStart,dragStop,focus and all
});

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM