0

I added this code in my PopUpWindow.js File.. in my scripts folder

var window = "<div id='window' style='display: none;width:190px'></div>";


PopUpWindow = function (titles, message, redirectURL) {
    document.getElementById('window').innerHTML = message;
    $("#window").dialog({
        resizable: true,
        height: 180,
        title: titles,
        width: 500,
        modal: false,
        open: function () {
            $('.ui-widget-overlay').show();
            $('.ui-dialog-titlebar-close.ui-corner-all').hide();
        },
        buttons: {
            "OK": function () {
                $(this).dialog("close");
                if (redirectURL) {
                    window.location = redirectURL;
                }
            }
        }
    });
};

I have Included this js file in Site.Master page.

But still i am not able to access this PopUpWindow function in any of my aspx page?

is that I am doing something worng?

I am not able to execte this PopUpWindow for showing the Popup Message

PopUpWindow("Field to Show","Message","URL redirect");

Thanks

2 Answers 2

1

Although "window" is being held in a variable, it is not added to the page anywhere before you try to get it by id.

    var window = "<div id='window' style='display: none;width:190px'></div>";


    PopUpWindow = function (titles, message, redirectURL) {

    // Add to body (change the selector to whatever's relevant)
    $('body').append( window );
    // Set the innerHTML the jQuery way :)
    $('#window').html( message );
    $("#window").dialog({
        resizable: true,
        height: 180,
        title: titles,
        width: 500,
        modal: false,
        open: function () {
            $('.ui-widget-overlay').show();
            $('.ui-dialog-titlebar-close.ui-corner-all').hide();
        },
        buttons: {
            "OK": function () {
                $(this).dialog("close");
                if (redirectURL) {
                    window.location = redirectURL;
                }
            }
        }
    });
};

I've only tested this on JSFiddle, and the CSS isn't there, so I can't guarantee there's not more wrong, but this does make a dialog appear if you change display to "block" on `#window'

Sign up to request clarification or add additional context in comments.

Comments

0

It would seem that either you are loading this file wrong (bad url) or something else is going on. Could you check and let us know? It could even be a syntax error.

EDIT: Did you forget to append window to your DOM?

var window2 = "<div id='window' style='display: none;width:190px'></div>";

$(window2).appendTo("body")

3 Comments

Thanks Nexxeus. the code which I mentioned that is the code i have it in my js file.. everything is same but I am not able to access this PopUpWindow dialogue?
IF i ADD Js file to my site.master page I am getting this Error in my page Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB0.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MDDR; .NET4.0C; .NET4.0E) Timestamp: Mon, 21 Mar 2011 18:27:44 UTC Message: Object doesn't support this property or method Line: 5 Char: 71822 Code: 0 URI: localhost:50189/Scripts/MicrosoftAjax.js Message: 'w.document' is null or not an object Line: 7
Edit I think this is because you are redefining the already in-use window object - try the code in my edit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.