English 中文(简体)
可变的Pixel跟踪
原标题:Scrollable Pixel Tracking

Hi I m 寻求一种途径,检测用户在引发事件之前的网页上(实时)有多少个餐厅。

我走过了这一法典,这是我之后的一件大事,但我需要收集整页,而不仅仅是一页。 我可以把四舍五入到整个网页的大小,因为它需要在单Pads/iPhones等上加油。

<head>
    <script type="text/javascript">
        function OnScrollDiv (div) {
            var info = document.getElementById ("info");
            info.innerHTML = "Horizontal: " + div.scrollLeft
                            + "px<br/>Vertical: " + div.scrollTop + "px";
        }
    </script>
</head>
<body>
    <div style="width:100px;height:200px; overflow:auto;" onscroll="OnScrollDiv (this)">
        Please scroll this field!
        <div style="height:300px; width:100px; background-color:#ccc;"></div>
        Please scroll this field!
        <div style="height:300px; width:100px; background-color:#ccc;"></div>
        Please scroll this field!
    </div>
    <br /><br />
    Current scroll amounts:
    <div id="info"></div>
</body>

An example of what i m after can be found at http://www.nikebetterworld.com/ Any help will be much appreciated.

Edit: it s at the bottom of the page!

问题回答

您在j Query中需要考虑的是scroll() activity,加上scrollTop(>方法。 你们可以利用这些手段来发现用户在滚动的网页上,以及你所需要的价值显示或隐藏的内容。

$(window).scroll(function() {
   var currentPosition = $(this).scrollTop();
   // do something with currentPosition...
});

您也可将这一方法应用于有<代码>over:适用于它们的滚动的异构元素以及<代码>window的物体。

Here s a fiddle to see it in action





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签