Create new tab

Создание вкладки с собственным контентом

by sazakharov

HTML

<input type="button" value="Create new tab" />

JavaScript

$(function(){
    $("input[type=button]").click(function(){
        var a = window.open('', ''),
            d = a.document,
            c = $("<div />").html("<h1>Контент вкладки</h1>"),
            f = $("<script />", {"type":"text/javascript"}).text("alert('open');");
        d.open("text/html");
        d.write("<!DOCTYPE html>");
        d.write("<html><head></head><body></body></html>");
        var head = $("head", $(d)).append($("<title />").text($(this).val()));        
        var body = $("body", $(d)).append(c);//.append(f);
        // через переменную head пихаем линки на стили, скрипты
        // через переменную body пихаем нужный контент
        d.close();
    });
})