Home >Web Front-end >HTML Tutorial >Urgently looking for website floating code that is compatible with IE and Firefox! (The parsing of IE9 and IE5, 6, 7, and 8 is different)_html/css_WEB-ITnose

Urgently looking for website floating code that is compatible with IE and Firefox! (The parsing of IE9 and IE5, 6, 7, and 8 is different)_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:09:401218browse

My existing code is only compatible with IE8 and below. IE9 and Firefox are not compatible. Please help me! !

<div id="codefans_net" visibility: visible; border:#A3DFF7 1px solid;></div><script language="JavaScript" type="text/javascript">    var x = 50, y = 60    var xin = true, yin = true    var step = 1    var delay = 10    var obj = document.getElementById("codefans_net")    function float() {        var L = T = 0        var R = document.body.clientWidth - obj.offsetWidth        var B = document.body.clientHeight - obj.offsetHeight        obj.style.left = x + document.body.scrollLeft        obj.style.top = y + document.body.scrollTop        x = x + step * (xin ? 1 : -1)        if (x < L) { xin = true; x = L }        if (x > R) { xin = false; x = R }        y = y + step * (yin ? 1 : -1)        if (y < T) { yin = true; y = T }        if (y > B) { yin = false; y = B }    }    var itl = setInterval("float()", delay)    obj.onmouseover = function() { clearInterval(itl) }    obj.onmouseout = function() { itl = setInterval("float()", delay) }    function close_float() { obj.style.visibility = 'hidden'; }</script>


Reply to discussion (solution)

This post is a living example

This post is A living example
This example is not compatible with IE9 and Firefox! I want a compatible one

That’s it, I’ll consider using ff to connect to csdn in the future

That’s it, I’ll consider using ff to connect to csdn in the future
Really! If you were asked to build a portal for a certain website, would you only consider users below IE8, but not IE9 and Firefox users? !

The problem with your code is that xx.style.top(left) is recognized by IE6, 7 and 8, but others such as FF, Google and IE9 are not recognized ~

The problem with your code is that xx.style.top(left) is recognized by IE6, 7 and 8, but others such as FF, Google and IE9 are not recognized~

The solution is to add 'px' after your value to achieve compatibility~

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn