2016-05-26 1 views
-1

私は新しいURLでpdfを開こうとしており、ユーザーをホームページにリダイレクトしています。しかし、これらの2行と3行の "if"ブロックはお互いを防ぎます。ページがホームページにリダイレクトされていますが、window.open()が機能していません。window.location.hrefとwindow.openはお互いを防ぎますか?

if(result.status == 'success'){ 
     hideSplashScreen(); 
     window.location.href = webContextPath+"/user/userhome"; 
     window.open(result.message, '_blank').focus(); 
} 
+0

ポップアップブロッカーは、それがFYI – epascarello

答えて

2

実はwindow.location.href = webContextPath+"/user/userhome";は、現在のページを離れるので、おそらくwindow.openが実行されることはありません...

は、あなたが最初にwindow.open(result.message, '_blank').focus();を呼び出すだけにしてwindow.location.href = webContextPath+"/user/userhome";しようとしたことがありますか?

+0

感謝をポップアップブロックされ、それが働きました。 –

1

シーケンスを反転:この最初のwindow.open(result.message、 '_blank')を呼び出します。最初

if(result.status == 'success'){ 
     hideSplashScreen(); 
     window.open(result.message, '_blank').focus(); 
     window.location.href = webContextPath+"/user/userhome"; 
} 
+0

ありがとう、それは働いた。 –