Recently learning Java Web, in the learning process to achieve a requirement, that is, when the JSP page jumps, I hope the new page after the jump opens in a new window,
Instead of covering the original page, this requirement puzzled me for a long time, and then, looking for a method on the Internet through a haystack, finally solved it,
Now this method to share with you, if there is a shortage of places, please forgive me, my original intention is to help people who have this need.
Before I have found a relatively reliable method on the Internet, is to add code in the corresponding location of the JSP page: target= "_black", such as
<a href= "Articleview?id=${article.id}" target= "_black" >${ARTICLE.TITLE}</A> the first click did play a role,
A successful new page is actually opened in a new window, but unfortunately, the second time you click on another connection, it overwrites the new window that was generated for the first time,
Did not generate a third new window, which makes people feel very depressed, using this method to achieve the above requirements is obviously not possible, then how to solve, the specific implementation method is as follows:
Use JS in the window.open () method to solve! Add the onclick attribute to the <a> tag and write this: onclick= "window.open (This.href); return false",
such as: <a href= "Articleview?id=${article.id}" onclick= "window.open (This.href); return false" >${article.title}< /a>,
So, the problem can be solved.
Reference: http://www.cnpc120.cn/pc/Article/Show27.html
Page Jump tips in Java Web development--new page opens in new window after jump