Url 如何关闭crossrider extension中的弹出图像?
我使用crossrider创建扩展,我使用这个简单的代码在浏览器上显示图像Url 如何关闭crossrider extension中的弹出图像?,url,crossrider,Url,Crossrider,我使用crossrider创建扩展,我使用这个简单的代码在浏览器上显示图像 $('<img style="position:fixed; z-index:999;margin-top:40%" />') .attr('src',('https://lh4.ggpht.com/9qGc5-maR10Fh1IpRlCuGSmge9Zzm8VQdPMNqjJkhZjtCvAQYX55MRoo4AYnYUdZhj7i=w300')) .prependTo('body');
$('<img style="position:fixed; z-index:999;margin-top:40%" />')
.attr('src',('https://lh4.ggpht.com/9qGc5-maR10Fh1IpRlCuGSmge9Zzm8VQdPMNqjJkhZjtCvAQYX55MRoo4AYnYUdZhj7i=w300'))
.prependTo('body');
$('
现在我想在图像上添加简单的x按钮来关闭图像,还想在该图像上添加链接,就像用户单击图像将打开新窗口一样。您可以使用标准jQuery来处理单击事件,并使用Crossrider来打开新窗口
因此,例如,根据extension.js文件中的代码使用以下内容,将创建所需的元素并提供所需的功能。我将根据需要将CSS设计留给您整理:
// Add div to contain the image and X button to the body element
$('<div id="my-wrapper" style="position:fixed; z-index:999;margin-top:40%"><img /><span>X</span></div>')
.prependTo('body');
// Configure the img src and add a click event handler that opens a new window
$('#my-wrapper img')
.attr('src',('https://lh4.ggpht.com/9qGc5-maR10Fh1IpRlCuGSmge9Zzm8VQdPMNqjJkhZjtCvAQYX55MRoo4AYnYUdZhj7i=w300'))
.click(function() {
appAPI.openURL({
url: 'http://example.com',
where: 'window'
});
});
// Add an event handler to the X button that closes/hides the image
$('#my-wrapper span')
.click(function() {
$('#my-wrapper').hide();
});
//将div添加到body元素中以包含image和X按钮
$('
[披露:我是一名交叉骑手员工]