I have an ASP.NET website and it's needed when user loads site homepage, a box pops up on page load (not a popup) with an image appear. When user clicks the image, it opens a link in a new tab?
I guess jQuery can do this or AJAX. I'm a noob in this! Hope you provide me with a sample functional code.
You could do something like this. The code below creates an image on document ready and binds a click event to it which when clicked, will open a new tab.
<script>
$(document).ready(function(){
var image = $('<img></img>').attr('id', 'my_image').attr('src', '/path/to/your/image.png')
$('#container').append(image);
$('#my_image').click(function(){
var window = window.open('http://your_url/', '_blank');
window.focus();
});
});
</script>
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.