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>
I dont know if this is exactly what your looking for. But by the way you said the following:
"when a user interacts with script , I want to make it open in a new tab"
I assume you mean when the script is executed "after html page is rendered" you want a new tab to be created, if so then this code will work both inline with your html or in its own script file.
//pure js
document.addEventListener("DOMContentLoaded", function(event) {
window.open('http://www.google.com');
});
// jquery
$(function() {
window.open('http://www.google.com');
});
++++++++
Per your latest reply.
You could setup a click listener for the ads, i'd suggest maybe using a shared css class amongst the ads and in JQuery setup a click listener like such. Maybe using 'Inspect Element' you can find a class name that each ads has and use the code below to listen to the click.
$('.class-name').click(function () {
window.open('http://www.theurlfromad');
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.