Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the commonly used encapsulation method in the front end of web

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what are the commonly used encapsulation methods in the front end of web?" in the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Magnifying glass

/ / execute after the page is loaded

_ window.onload=function () {

VaroDemo=document.getElementById ('demo')

VaroMark=document.getElementById ('mark')

VarFloatBox=document.getElementById ('float-box')

VarSmallBox=document.getElementById ("small-box")

VarbigBox=document.getElementById ('big-box')

VarbigImg=bigBox.getElementsByTagName ('img') [0]

OMark.onmouseover=function () {

FloatBox.style.display= "block"

BigBox.style.display= "block"

}

OMark.onmouseout=function () {

FloatBox.style.display= "none"

BigBox.style.display= "none"

}

OMark.onmousemove=function (ev) {

Varev=ev | | window.event

Varleft=ev.clientX-oDemo.offsetLeft-SmallBox.offsetLeft-FloatBox.offsetWidth/2

Vartop=ev.clientY-oDemo.offsetTop-SmallBox.offsetTop-FloatBox.offsetHeight/2

If (left=oMark.offsetWidth-FloatBox.offsetWidth-10) {

Left=oMark.offsetWidth-FloatBox.offsetWidth

}

If (top=oMark.offsetHeight-FloatBox.offsetHeight-10) {

Top=oMark.offsetHeight-FloatBox.offsetHeight

}

FloatBox.style.left=left+ "px"

FloatBox.style.top=top+ "px"

VarscaleX=left/ (oMark.offsetWidth-FloatBox.offsetWidth)

VarscaleY=top/ (oMark.offsetHeight-FloatBox.offsetHeight)

BigImg.style.left=-scaleX* (bigImg.offsetWidth-bigBox.offsetWidth) + "px"

BigImg.style.top=-scaleY* (bigImg.offsetHeight-bigBox.offsetHeight) + "px"

}

}

2 、 JSONP

Functionfn1 (data) {

Varhtml=''

VaroUl=document.getElementsByTagName ('ul') [0]

Console.log (data)

If (DATA. Totalcake colors Muffle 1) {

For (vari=0;i

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report