在unload事件上需要srcElement的帮助 [英] Need help with srcElement on unload event

查看:68
本文介绍了在unload事件上需要srcElement的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,如果他试图退出页面,我需要向用户显示弹出窗口。我已经写了一个onunload函数,它负责显示弹出窗口。但是,如果用户单击站点上的某些链接,则不应向用户显示弹出窗口。这些链接还会导致页面被卸载。我正在使用srcElement来识别已单击的链接。不幸的是,在我的函数中,srcElement对象变为null。我厌倦了请求帮助。如果有任何代码示例,我会非常有帮助。

I have a page on which i need to show a pop up to the user if he tries to exit the page . I have already written an onunload function which takes care of displaying the popup . But the popup should not be displayed to the user if the user clicks on certain links on the site . These links also cause the page to be unloaded. I am using the srcElement to identify which link has been clicked . Unfortunately , in my function srcElement object is coming null . I am tired of trying please help. If there are any code samples i would be really helpful.

推荐答案

嗨...


欢迎来到TSDN .. 。


请发一些你已经存在且与你的问题有关的代码...


亲切的问候
hi ...

welcome to TSDN ...

please post some code that you have already and that relates to your problem ...

kind regards


Heya,Nileshs。欢迎来到TSDN!


更改主题标题以更好地描述问题。


让特定链接设置一个卸载功能检查的全局变量在显示弹出窗口之前。
Heya, Nileshs. Welcome to TSDN!

Changed thread title to better describe the problem.

Have the specific links set a global variable that your unload function checks for before showing the popup.


谢谢你们

下面是我编写的示例代码。我只是想让这个工作。

我稍后会将它集成到我的应用程序中。


[HTML]<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.0 Transitional // EN">

< HTML> ;

< HEAD>

< TITLE>新文档< / TITLE>

< script>

函数showSource(){

var x = window.event.srcElement;

alert(" Source Elemt" + x);

var y = window.event.type;

alert(" Source Event) + y);

}

< / script>

< / HEAD>

< ; BODY onUnload =" showSource();">

< A id =" google" HREF =" http://www.google.com"> Google< / A>

< A id =" yahoo" HREF =" HTTP://www.yahoo.com" > Yahoo< / A>

< / BODY>

< / HTML> [/ HTML]
Thanks guys
Below is a sample code that I have written. I am just trying to make this work .
I will integrate it into my application later.

[HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<script>
function showSource() {
var x= window.event.srcElement;
alert("Source Elemt "+x);
var y = window.event.type;
alert("Source Event "+y);
}
</script>
</HEAD>
<BODY onUnload="showSource();">
<A id="google" HREF="http://www.google.com">Google</A>
<A id="yahoo" HREF="http://www.yahoo.com" >Yahoo</A>
</BODY>
</HTML>[/HTML]


这篇关于在unload事件上需要srcElement的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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