简体   繁体   中英

How to check if a page's content has been modified?

1 - I have a web page, in that page there are many external links

2 - When user click on any external link then a popup should be come with the message that page has been modified by dynamic action or it not.

3 - How can I check the page status using JavaScript / jQuery?

Thanks in advance.

Add some state variable to javascript, like:

wasModified = false;

Subscribe on click event of every external link or whatever you want to react on, like that:

$('.external-link-class-selector').click(function(){
    wasModified = true;
    //in case click mean it was modified and you should notify user
    alert('Page was modified');
});

see

 $.ajax({
         url: "",
         type: "post",
         dataType: "" ,
         data: , 
        }).done(function() {
                //sucess
                            });

make a function in Javascript including above function and Post values by this method to the same page and append success message on the page.

您可以更改窗口/主体的“ onhaschange”事件,只需设置一些标志即可检查链接的单击以显示页面是否被更改。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM