So when a user interacts with <script>
, I want to make it open in a new tab.
I tried doing this:
<script target="_blank"
but that didn't work. Help please!
EDIT: I'm sorry for not making myself that clear. I meant that when a user clicks on my bidvertiser ads, I want the ads to open on a new page. they are in script form so when the user clicks on the script, I want to open the script in a new page sort of like <a target="_blank>
答案 0 :(得分:1)
我不知道这是不是你想要的。但顺便提一下你说的话:
&#34;当用户与脚本交互时,我想在新标签页中打开它&#34;
我假设您的意思是在执行脚本时#34;在呈现html页面之后#34;您希望创建一个新选项卡,如果是这样,那么此代码将与您的html或其自己的脚本文件内联。
//pure js
document.addEventListener("DOMContentLoaded", function(event) {
window.open('http://www.google.com');
});
// jquery
$(function() {
window.open('http://www.google.com');
});
++++++++
根据您的最新回复。
您可以为广告设置点击监听器,我建议可以在广告中使用共享的css类,并在JQuery中设置一个类似的点击监听器。也许使用&#39; Inspect Element&#39;您可以找到每个广告所拥有的类名,并使用下面的代码收听点击。
$('.class-name').click(function () {
window.open('http://www.theurlfromad');
});