对话框关闭的第二部分 [英] Second Part to Dialog Closing

查看:64
本文介绍了对话框关闭的第二部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我从这里开始的第一个第二线程:

This is a 2nd thread of a first I started here: I Created A Dialog, Now How Can I Close It?

我正在创建一个新线程,以便可以包含更新的代码.

I'm creating a new thread so I can include updated code.

首先,我想向所有在上面的链接中帮助过我的人致以深深的感谢,但是正如我所说的,我正在启动此线程,以便我可以添加代码示例.

First of all I'd like to give an enormous THANKS to all whom have helped me in the post linked above but as I stated, I'm starting this thread so I can add code samples.

我在某些页面上有一个对话框,该对话框出现在滚动页面上,但是我遇到了一些麻烦.

I have a dialog on some of my pages that appears onscroll but I'm having some trouble.

可以在此处看到此对话框:(出现的半透明框)

This dialog can be seen here: (The semi transparent box that appears) http://classifieds.your-adrenaline-fix.com/detail.php?fatherID=37&TypeID=42&ListingID=42

在detail.php上,我有:
(在头部)

On detail.php I have:
(in the head)

    <script type="text/javascript">
    function loaddiv(thediv, thefile) {
        if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
        } else {
        xmlhttp = new ActiveXObject ('Microsoft.XMLHTTP');
        }

        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                document.getElementById(thediv).innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open('GET', thefile, true);
        xmlhttp.send();
    }
    </script>

以下:

    <body onscroll="loaddiv('div2', 'do-you-have-a-dirt-bike-for-sale.html')">

然后:

    if (!Has_Seen_DB_For_Sale_Dialog($user_ip)){
        echo "<div id='div2'></div>";
        ip_add($user_ip);
    }

在包含文件中,我有:

    function Has_Seen_DB_For_Sale_Dialog($ip){
        global $user_ip;
        $query ="SELECT `IP` FROM `DB_For_Sale_Dialog` WHERE `IP`='$user_ip'";
        $query_run = mysql_query($query);

        $query_num_rows = mysql_num_rows($query_run);
        if($query_num_rows==0){
            return false;
            }   else if($query_num_rows==1){
            return true;
        }
    }

    function ip_add($ip){
        $query = "INSERT INTO `DB_For_Sale_Dialog` VALUES('', '$ip') ";
        @$query_run = mysql_query($query);
    }

显示的文件如下:

<div id='div2'>
    <div class="DoYouHaveADirtBikeForSaleBox" id="DoYouHaveADirtBikeForSaleBox">
    <h2>Got A Dirt Bike You Want to Sell?</h2>
    <p class="DirtBikeForSaleBannerButton">
    <a href="http://classifieds.your-adrenaline-fix.com/add.php">Yea, Show Me How</a>
    </p>

    <p class="DirtBikeForSaleBannerButtonNoThanks">
    <a onclick="javascript:var div = document.getElementById('div2');div.parentNode.removeChild(div);">Nope, Get This Out of The Way</a></p> 
    </div>
    </div>

我非常感谢在上一个线程中为我提供的帮助,并不意味着不尊重启动新线程,但是我现在遇到的问题是:

I'm VERY Grateful of the help provided me in my last thread and mean NO disrespect in starting a new thread but What I'm now having trouble with is:

当我将鼠标悬停在右键上以关闭该框时,指针不会像其他链接一样变成手形.

When I hover over the right button to close the box, the pointer doesn't turn into a hand as it does with other links.

关闭对话框并滚动页面时,该框会再次出现.(显示框的功能称为onscroll,但我只希望框显示一次.

When the dialog box is closed and the page is scrolled, the box reappears. (the function to display the box is called onscroll but I only want the box to appear ONCE.

如果有人不介意对此发表评论,我将非常感激,我当然希望您的答复.

If anyone wouldn't mind commenting on this I'd be most appreciative and I certainly look forward to your responses.

非常感谢,斯图尔特K

Thanks So Much, Stuart K

推荐答案

使用此方法:

<script type="text/javascript">
function loaddiv(thediv, thefile) {
    if (window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest();
    } else {
    xmlhttp = new ActiveXObject ('Microsoft.XMLHTTP');
    }

    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            document.getElementById(thediv).innerHTML = xmlhttp.responseText;
            window.onscroll = null;
        }
    }
    xmlhttp.open('GET', thefile, true);
    xmlhttp.send();
}

</script>

--------我做了这个小测试----------------

--------I made this little test--------------

function loaddiv() {
alert('hiiii');
window.onscroll = null;

        }

身体叫声:

<body onscroll="loaddiv();"> 

并且只能运行一次xD

And works just once xD

礼炮.

这篇关于对话框关闭的第二部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆