


js implementation code for picture-in-picture advertising in the information page (how to load ads in the text)_javascript skills
The editor of Script House gave me the code directly:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>文中加载广告方式</title> <script type="text/javascript" src="http://img.jb51.net/jslib/jquery/jquery.min.js"></script> </head> <body> <div class="content" id="articleText"> <p>每天都有一个明天,在我们的心中,明天总是美好明亮的。快乐的面对未来,积极的对待生活,让生活充满花香。</p> <p>现代诗歌,是充满活力充满力量的一种文体。当积极向上的内容用现代诗歌展现出来时,似乎正能量饱满而又精神的阳光一般。让我们沐浴阳光,天天向上!</p> <p><strong>一、《自信》</strong></p> <p>不要马马虎虎<br />不要三心二意<br />追求绝对的准确<br />追求相对的完美<br />就算一个字也要写好<br />才会真正的收获快乐</p> <p>无论在任何时候<br />都要对自己充满信<br />无论遇到任何羁绊<br />都要坚定向前<br />相信自己是最棒的<br />所有的困难都会被击垮</p> <p><strong>二、《跨越自己》</strong></p> <p>我们可以欺瞒别人<br />却无法欺瞒自己<br />当我们走向枝繁叶茂的五月<br />青春就不再是一个谜</p> <p>向上的路<br />总是坎坷又崎岖<br />要永远保持最初的浪漫<br />真是不容易<br />有人悲哀<br />有人欣喜<br />当我们跨越了一座高山<br />也就跨越了一个真实的自己</p> <p><strong>三、《倘若才华得不到承认》</strong></p> <p>倘若才华得不到承认<br />与其诅咒,不如坚忍<br />在坚忍中积蓄力量<br />默默耕耘<br />诅咒,无济于事<br />只能让原来的光芒黯淡<br />在变得黯淡的光芒中<br />沦丧的更有,大树的精神<br />飘来的是云<br />飘去的也是云<br />既然今天<br />没人识得星星一颗<br />那么明日<br />何妨做,皓月一轮</p> <p><strong>四、《我微笑着走向生活》</strong></p> <p>我微笑着走向生活,<br />无论生活以什么方式回敬我。<br />报我以平坦吗?<br />我是一条欢乐奔流的小河。<br />报我以崎岖吗?<br />我是一座大山庄严地思索!<br />报我以幸福吗?<br />我是一只凌空飞翔的燕子。<br />报我以不幸吗?<br />我是一根劲竹经得起千击万磨!<br />生活里不能没有笑声,<br />没有笑声的世界该是多么寂寞。<br />什么也改变不了我对生活的热爱,<br />我微笑着走向火热的生活!</p> <p><strong>五、《热爱生命》</strong></p> <p>我不去想是否能够成功<br />既然选择了远方<br />便只顾风雨兼程</p> <p>我不去想能否赢得爱情<br />既然钟情于玫瑰<br />就勇敢地吐露真诚</p> <p>我不去想身后会不会袭来寒风冷雨<br />既然目标是地平线<br />留给世界的只能是背影</p> <p>我不去想未来是平坦还是泥泞<br />只要热爱生命<br />一切,都在意料之中</p> <p><strong>六、《献给黄昏的星》</strong></p> <p>黄昏的星从大地海洋升起<br />我站在黑夜的尽头<br />看到黄昏像一座雪白的裸体<br />我是天空中唯一一颗发光的星星</p> <p>在这艰难的时刻<br />我仿佛看到了另一种人类的昨天<br />三个相互残杀的事物被怼到了一起<br />黄昏,是天空中唯一的发光体<br />星,是黑夜的女儿苦闷的床单<br />我,是我一生中无边的黑暗</p> <p>在这最后的时刻,我竟能梦见<br />这荒芜的大地,最后一粒种子<br />这下垂的时间,最后一个声音<br />这个世界,最后的一件事情,黄昏的星</p> <p><strong>七、《山高路远》</strong></p> <p>呼喊是爆发的沉默<br />沉默是无声的召唤<br />不论激越<br />不是宁静<br />我祈求<br />只要不是平淡<br />如果远方呼喊我<br />我就走向远方<br />如果大山召唤我<br />我就走向大山<br />双脚磨破<br />干脆再让夕阳涂抹小路<br />双手划烂<br />索性就让荆棘变成杜鹃<br />没有比脚更长的路<br />没有比人更高的山</p> </div> <div class="clear"></div> <div style="float:left;margin:10px 10px 10px 0;display:none" id="article_ad0"> <script type="text/javascript"> var sti; var resize = function (temp, ad) { var timer, count = 0, limit = 50; timer = setInterval(function () { var tempOffset = temp.offset(); var adOffset = ad.offset(); count += 1; ad.css({ left: tempOffset.left, top: tempOffset.top }); if (count >= limit || adOffset.top === tempOffset.top) { clearInterval(timer) } }, 100); }; function check_show(container, caid, order) { var ad = $('#' + caid); var offset; var temp = $('<div>').css({ 'float': 'left', width: ad.width(), height: ad.height(), margin: '10px 10px 10px 0' }); if (ad.height() > 10) { $("#" + container + " p").eq(order).after(temp); offset = temp.offset(); ad.css({ position: 'absolute', left: offset.left, top: offset.top }).show(); resize(temp, ad); clearInterval(sti); } } function weneiAd(container,aid){ var p = $("#"+container).find("p").size(); var img = $("#"+container).find("img").size(); var caid='article_ad0'; var order=0; if(img>1&&p<=3){ }else if(img==1&&p>3){ order=1; }else if(img==0&&p>3){ order=1; }else if(img>1&&p>5){ order=5; } if(order>0){ //document.write("<div style=\"float:left;margin:10px 10px 10px 0;display:none\" id=\""+caid+"\">"); document.write('<font color=red>脚本之家信息页文内画中画开始</font>'); document.write("<font color=red>脚本之家信息页文内画中画结束</font>"); // document.write("<\/div>"); //document.write("<div style='clear:both'><\/div>"); sti=setInterval(function () { check_show(container,caid,order);},500); } } weneiAd('articleText',4); </script> </div> </body> </html>
Core js code:
<script type="text/javascript"> var sti; var resize = function (temp, ad) { var timer, count = 0, limit = 50; timer = setInterval(function () { var tempOffset = temp.offset(); var adOffset = ad.offset(); count += 1; ad.css({ left: tempOffset.left, top: tempOffset.top }); if (count >= limit || adOffset.top === tempOffset.top) { clearInterval(timer) } }, 100); }; function check_show(container, caid, order) { var ad = $('#' + caid); var offset; var temp = $('<div>').css({ 'float': 'left', width: ad.width(), height: ad.height(), margin: '10px 10px 10px 0' }); if (ad.height() > 10) { $("#" + container + " p").eq(order).after(temp); offset = temp.offset(); ad.css({ position: 'absolute', left: offset.left, top: offset.top }).show(); resize(temp, ad); clearInterval(sti); } } function weneiAd(container,aid){ var p = $("#"+container).find("p").size(); var img = $("#"+container).find("img").size(); var caid='article_ad0'; var order=0; if(img>1&&p<=3){ }else if(img==1&&p>3){ order=1; }else if(img==0&&p>3){ order=1; }else if(img>1&&p>5){ order=5; } if(order>0){ //document.write("<div style=\"float:left;margin:10px 10px 10px 0;display:none\" id=\""+caid+"\">"); document.write('<font color=red>脚本之家信息页文内画中画开始</font>'); document.write("<font color=red>脚本之家信息页文内画中画结束</font>"); // document.write("<\/div>"); //document.write("<div style='clear:both'><\/div>"); sti=setInterval(function () { check_show(container,caid,order);},500); } } weneiAd('articleText',4); </script>
Mainly the ordering university controls the position of the advertisement, and you can modify it as needed.
This requires loading jquery. Of course, there are some methods on the Internet that need to judge the character length and intercept them, and they are all good.
Of course, there are a lot of advertisements now and they are well controlled. You can go to Sina.com and check out the advertisements on its content pages. There are also in-text advertisements.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article brought to you in this chapter is about the computer version of the computer version software. Do you know where the picture-in-picture is in the computer version of the computer version? Next, the editor will help you find the picture-in-picture position in the computer version of the computer version. Method, interested users can take a look below. First open the computer version of the clip. Click the Start Creating button. Click on the video material you want to import and add the video file you want to edit. Then drag the file to the editing area. The professional version of Cutting Computer does not have the picture-in-picture function, but we can achieve the picture-in-picture function by adding materials again. Also drag the newly added video file to the video editing track. In this way, select the material file and adjust the video size to realize the picture-in-picture function of the mobile phone.

How to Set Zoom to Picture-in-Picture Mode on iPhone Make sure your iPhone is using the latest version of iOS and that the Zoom app is updated to the latest version available. The rest is simple: join the Zoom meeting as usual with the video as the home screen on your iPhone (i.e.; no chat, no participant list, etc.) Swipe up from the bottom of your iPhone as usual to return to the home screen The Zoom Meeting video window should automatically Minimize to Picture-in-Picture Video Just like any other Picture-in-Picture window, you can move it around the screen, increase and decrease the thumbnail size, and use other applications as the ZoomMeetingPiP window

YouTube began officially rolling out picture-in-picture to its iOS app in June last year, which was a very slow process. Premium subscribers got a workaround, but YouTube's picture-in-picture test for iPhone and iPad is now over. The "Picture-in-Picture on iOS" experiment (which started in August) has disappeared from youtube.com/new after ending in early April. Google notifies people with a "The feature you are trying is turned off" banner on the desktop website and mobile app. That said, YouTube PiP is still available to iPhone and iPad users who previously enabled the test. It doesn't work on the iPad where we actively use the PiP

How to implement picture-in-picture and multiple exposure of pictures in Vue? Introduction: In modern web design, the display effect of images is a very important link. Picture-in-picture and multiple exposure are two common photo manipulation effects that can make pictures more vivid, unique and attractive. This article will introduce how to use the Vue framework to achieve these two effects and provide relevant code examples. 1. Picture-in-picture effect realization Picture-in-picture is an effect in which a small-sized picture is nested in another large-sized picture. The key to achieving picture-in-picture effect is to use C

Workaround for using YouTube Web Picture-in-Picture on iPhone and iPad We'll be using the Shortcuts app as a workaround, but you can access this tool from the iOS share sheet menu while watching YouTube videos in Safari. No, it doesn't work with the official YouTube app. Before you begin, you need to set up your device to install third-party shortcuts. Once done, follow these steps: First, head to this link and tap "Get Shortcut" to download the YouTube PiP shortcut on your iPhone or iPad. This will launch Shortcuts on your device

Microsoft’s official blog announced today that it has released the Windows 11 Android subsystem version 2303.40000.3.0 update to all Windows Insider channels. The update will improve reliability and security and bring Picture-in-Picture (PIP) mode to users. Picture-in-picture is a video content presentation method, which means that while one video is played in full screen, another video is simultaneously played in a small area of the screen. According to reports, the Windows 11 Android subsystem now supports the App’s picture-in-picture function. Apps in window mode will support Windows resizing and alignment functions to facilitate users for multitasking. We have tested that the small window mode of station B can be displayed normally, but there are still some problems with the operation and it cannot

Do you know how to enable the picture-in-picture video control in Firefox? Below, the editor will bring you how to enable the picture-in-picture video control in Firefox. I hope it will be helpful to you. Let’s follow the editor to learn it! 1. Open the Firefox browser and select the icon with three lines in the upper right corner, as shown in the figure below. 2. Click Options from the pop-up window, as shown in the figure below. 3. Check the box to enable picture-in-picture video control, as shown in the figure below. The above is the entire content of how to enable picture-in-picture video control in Firefox browser brought to you by the editor. I hope it can be helpful to you.

1. Open the phone settings and click [General]. 2. Click the [Picture in Picture] option. 3. Turn on the switch of [Automatically turn on picture-in-picture].
