开发者

Redirect from iframe to the new window

开发者 https://www.devze.com 2022-12-18 18:05 出处:网络
I have been building widget that accept user input and then once everything checked it will redirect user to the original web site.

I have been building widget that accept user input and then once everything checked it will redirect user to the original web site.

However the best I achieved for now is that redirect will be opened in parent window rather then in new window.

Right now I am using

$(parent.location).attr('href', asoRequestURL);

However I would like to open redirected page in new window rather then in开发者_如何学运维 parent windows.

Is it possible ? And if yes then can you give me example.

Thanks in advance


Is there some horrible problem with window.open(asoRequestURL);? I know it's not technically jQuery, but so far as I can tell it would take a plugin to be able to do. Is it really worth downloading a plugin to replicate such simple functionality?

EDIT: Here is all the information you could ever want on window.open(); it may not be ultraclean jQuery smooth, but this isn't really what jQuery is meant for.

Here is a function to make it ultra-cool-smooth using objects for parameters and such:

function openWin(url, name, params) {
    if (params != undefined && typeof params == 'object') {
        var paramStr = '';
        for (var p in params) {
            paramStr += p + '=' + params[p] + ',';
        }
        paramStr = paramStr.substr(0, paramStr.length - 1);
        window.open(url,name,paramStr);
    }
    else {
        window.open(url,name);
    }
}

And use it like:

openWin('http://blah-blah/', 'myWin', {width: 400, height: 400, menubar: 'no'});


To open a new window in Javascript:

window.open('http://example.com');

Pop-up blockers, however, may refuse to open the window, so be prepared.


If you want to modify the parent URL...

 parent.location.href = 'http://www.example.com/';

If you want to open in a new window...

 window.open('http://www.example.com/', 'nameWithoutSpaces', '{features}');


What about doing it in a hyperlink and controlling the behavior of the hyperlink (if it can be clicked or not) via javascript.

<a href='http:://example.com' target='_blank'>example</a>
0

精彩评论

暂无评论...
验证码 换一张
取 消