I would first say that support for the "javascript:" protocol is
pretty strong in older browsers.
However, if feasible and for browsers were it is supported, I would
suggest to use a "data:" URI as in:
window.open('data:text/html,')
instead of the "javascript:" protocol. I haven't tested on IE < 9 but
seems to work in all newer browsers.
On IE < 9 using the "about:blank" URL will probably be safer, if I
recall correctly there were request to completely remove the
"javascript:" protocol functionality or at least restrict it only to
anchor elements so it is at least risky to hope it will be there in
future.
The other drawbacks in using the "javascript:" protocol are pop-up
blockers and proxies where those URL could be modified/blocked.
--
Diego Perini
On Wed, Apr 13, 2011 at 12:52 PM, Poetro <[email protected]> wrote:
> 2011/4/13 Sean Kinsey <[email protected]>:
>> If there is an existing window open with the same name as referenced in the
>> `window.open(url, name)` statement, then this window will normally be
>> targeted instead of opening a new one (and having it blocked).
>> This has lead me do the following; identify the name used by the blocked
>> window.open code, and then on your site, in the users click action open up
>> a window with the same name. The window.open statement will now target the
>> existing window and is therefor not blocked.
>> You might need to open some document on the same domain as the window.open
>> code tries, but a 404 should suffice in this case.
>> Sean
>
> You dont need to open a valid URL with window.open. The following will do:
>
> var message = 'Opening page',
> win = window.open('javascript:"' + encodeURIComponent(message) +
> '"', yourwindow),
> doc = window.document;
> doc.write('<!DOCTYPE HTML><html lang="en-US"><head><meta
> charset="UTF-8"><title>' +
> message + '</title></head><body>' +
> message + '</body></html>');
> doc.close();
>
> And then when some event happens, just:
>
> win.location.replace('http://www.example.com/');
>
> --
> Poetro
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
>
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]