Javascript banner link open in new window

笑着哭i 提交于 2019-12-11 18:32:45

问题


I have a page with a JavaScript code:

http://pastehtml.com/view/1d997i8.html

please view source code

When you open the page a random banner will be displayed. When I click on the banner, i want to open the link on the banner in a new window.

Right now it opens on the same window.

Any help is appreciated. Thank you


回答1:


< a href="somehwere" target="_blank">yay a new window< /a >

You need to set the "target" attribute in the link




回答2:


You could use jQuery and include the following in the script:

$('a').attr('target','_blank');



来源:https://stackoverflow.com/questions/5013225/javascript-banner-link-open-in-new-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!