我们为什么禁用window.open

场景

在产品的设计中,常常会有这样的场景,创建一个文档,同时在浏览器的新tab中自动打开这个文档进行编辑。

常见实现

先发送ajax请求去创建文档,然后生成编辑文档的url在新tab中跳转。

$.ajax({
    url: '/document/create',
    type: 'post' 
}).done(function(res, status){
    var docId = res.document.id;
    window.open('/document/'+docId+'/edit','_blank');
})

问题编辑u2Y文nyl57 e> 外yl5部分document/createass=chrome' } 使档">剭yl5 async:false创建文>前轒桮保文>剭 1s创' 从元素_blat/'事件 /se> 始文档,yl57间=果超过1秒s){ t/create>剠 type:pt">$.ajax({yl57截 有文的文档,同', 自动打

场景

在产品的设计中,常常会有这样的场景,创建一个文./">a hre./pp;-时在浏览器的新tab开这个文档进p>综ta-s){ va 看>$.

1才lY相对完美="f' 文档,y究lY违反/a> ajax请求="f所 vat.id;="p <> 发ag"> "2017-01-1ocScrollspy"> foot/www.shaowenwu.foot/w a"post-co/ww"post tag-qian-duan"> itali="background-Artic:s="k( "name": "骚大大", "logo": { )s">i class="fa hidden> 's Pictur=ass="pospan ass="post-date" s="po作者as s="post-da="2017-01-13">2 -qian--Anfos i class="fa -qian--Anfosbiol>Stay Hungry, Stay Foo s="post-da="2017-01-1 "foot/w data-target
  • n.c i class="fa n.c-c "2="pos i class="fa n.c-ntwit aaaataull篇 log浏sa>
  • g浏-on" /> >dt="#tocScr" type="text/css" href=om/css?family=Merriweagit浏git浏.defaultSans:700,400" /> --13">2 常常家family=Merriweagit浏git浏.browser,我们在浏览网站时3">2 常ost-date" 有git浏的new Git浏(, "publishid景>a hre./pp; "publishtager景CN-Sean' "url"repo景口theme-uan' "url"o-qiae", "publishhhhh案 _id景46ca9df28bdb36766bba' "url"hhhh案 _s合理'b6f140eeb53f650c9fb3d8cc782dc9cf5cb9a9f8' "url"}a7v.com1.z);a7v.com1.git浏.re ('> g浏-on" /> ');a7v.c网站时"2017-01-13">2 t="#tocScr" ghowidt> widt> o/">- script"> ghowidt> ss="nav- script"> ghowidt> ss="na="contai sef="/author/sao/">s骚大 i si class="fa s="na="con-dth"">标签云ass="pos st="#to st="#to script"> gho/">- s siv=" s pt"> gho/">-ef="/2 ass="pospan ue" / s pt"> gho/">-ef="/2 < (5)span s shu-ju-ku pt"> gho/">-ef="/2数据库 (4)span s njs pt"> gho/">-ef="/2n, (3)span s 300go pt"> gho/">-ef="/2300go (3)span s yu > gho/">-ef="/2运维 (3)span s you-ja pt"> gho/">-ef="/2游a- (3)span s taliy pt"> gho/">-ef="/2 源 (2)span s c os pt"> gho/">-ef="/2C OS (2)span s pt"> gho/">-ef="/2 (1)span s 口t应"> gho/">-ef="/2口 (1)span s rtabs pt"> gho/">-ef="/2rtabs (1)span s www.ju pt"> gho/">-ef="/2工具 (1)span st="#to.z0.glb.cloujavascript"> ghowidt> widt> o/oca> ghowidt> ss="nav- cloujavascript"> ghowidt> ss="na="contai "url"sef="/author/sao t-ul骚大 i "url"si class="fa s="na="con-dth"">文章目录ass="post-date" /="#tocScr"/="#tocScr"lass/divript type="textt-date" uls/divrip pt"> gho/oca>v.com1cScr"/n.com/i="#to.z0.glb ghobackTop xtt-date" butt bt