Shaggy
Shaggy

Reputation: 5800

write content to newly open window using jQuery

I have a function written on some another page load event.i want to open new page and write content (such as textbox value) to newly opened page

function updateUser() {
    $("button").on("click", function () {
        var code = $(this).attr('id');        
        $.ajax({
            url: '/ajaxExecute.aspx?Fn=GETUSERFORUPDT',
            type: 'POST',
            context: document.body,
            data: 'Code=' + code,
            cache: false,
            success: function (response) {
                if (response != 'undefined') {
                    window.location = 'AddEditUser.aspx';
                    $('#txtUserName').val(response.split("|")[0]);                    
                }                
            }
        });
    });
}

Textbox with id txtUserName lies in page AddEditUser.aspx & function updateUser() load in another .aspx page

My Page loads but not able to get value in textbox as i am able to get value using alert()

I refer this links but still cudnt figure out

Write Content To New Window with JQuery

New window with content from modal content on opener page

Upvotes: 0

Views: 120

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1075039

If you mean (as you seem to from the sample code) that you want to open a new page in the same window and then write the value to a textbox on that page afterward, you can't do that.

Alternatives:

  1. Pass it as a query string parameter to the new page.

  2. Save it as a cookie and have the subsequent page read the cookie.

  3. Save it in local storage (which is a lot like the cookie option).

I can think of a couple of other options, but what all of these have in common is that they require that the receiving page do something. There's no way to drive this from the sending page alone.

Upvotes: 2

Related Questions