IE中的onbeforeunload和eval问题 [英] onbeforeunload and eval Problems in IE

查看:67
本文介绍了IE中的onbeforeunload和eval问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用onbeforeunload客户端事件来提示用户

在他们进行更改后离开页面,如本文所讨论的那样

文章:使用ASP .NET在离开页面时提示用户保存

[ http://aspnet.4guysfromrolla.com/art...101304-1.aspx] 。问题

我正在通过eval页面卸载。具体来说,我使用telerik r.a.d.

。菜单

[ http://telerik.com /Default.aspx?PageId=1415] ,通过以下脚本将用户重定向到

另一页:


eval(''窗口。 location.href =''菜单项的网址'');


当用户试图通过菜单选项离开页面时,他们会得到

提示,如预期的那样,但如果他们单击取消则会出现脚本错误:

eval()函数调用的行号未指定错误。这个

在Firefox中运行得很好。


我创建了一个非常简单的页面来测试它并确认它是

eval()函数。下面的页面,当通过IE访问时,显示

提示,如果我点击取消我得到相同的未指定错误。


< script>

函数foo()

{

返回" bar" ;;

}


window.onbeforeunload = foo;


eval(''window.location.href = \''http://www.google.com \'''' ');

< / script>

我无法通过谷歌找到任何关于这是否知名的信息

bug或者是否有任何变通方法。任何想法/建议/意见

非常感谢。 (我也在telerik论坛上发帖;

希望有一种简单的方法可以摆脱那些eval()语句,

但是我怀疑它......)


TIA

I am using the onbeforeunload client-side event to prompt a user when
leaving a page after they have made changes, as discussed in this
article: Using ASP.NET to Prompt a User to Save When Leaving a Page
[http://aspnet.4guysfromrolla.com/art...101304-1.aspx]. The problem
I am having is with the page unloading via eval. Specifically, I am
using telerik r.a.d. menu
[http://telerik.com/Default.aspx?PageId=1415], which redirects users to
another page via script like:

eval(''window.location.href=''url of menu item'');

When a user attempts to leave the page via a menu option, they get the
prompt, as expected, but if they click Cancel there is a script error:
Unspecified error on the line number of the eval() function call. This
works just fine in Firefox.

I created a VERY simple page to test this out and confirm that it is
the eval() function. The page below, when visited through IE, displays
the prompt and if I click Cancel I get the same Unspecified error.

<script>
function foo()
{
return "bar";
}

window.onbeforeunload = foo;

eval(''window.location.href=\''http://www.google.com\'''');
</script>

I was unable to find any info via Google as to if this is a well-known
bug or if there are any workarounds. Any ideas/suggestions/comments
most appreciated. (I''m posting this in the telerik forums as well;
hopefully there''s an easy way to get rid of those eval() statements,
but I doubt it... )

TIA

推荐答案

Scott Mitchell写道:

< snip>
Scott Mitchell wrote:
<snip>
eval(''window.location.href = \''http://www.google.com \'''');
< / script>
< snip>希望有一种简单的方法可以摆脱那些eval()
语句,但我对此表示怀疑......)
eval(''window.location.href=\''http://www.google.com\'''');
</script> <snip> hopefully there''s an easy way to get rid of those eval()
statements, but I doubt it... )




不,很容易摆脱那个 - eval - 电话。你只需删除它: -


window.location.href =''http://www.google.com'';


Richard。



No, its easy to get rid of that - eval - call. You just remove it:-

window.location.href = ''http://www.google.com'';

Richard.


eval语句嵌入在特定ASP.NET

Web控件(telerik'的rad菜单)的逻辑中。删除eval()并不像你想象的那么简单。基本上,在
中有一个JavaScript函数,用于r.a.d的脚本库。菜单执行传递内容的评估

in,以及特定命令 - window.location.href ... - 可能是

传入,具体取决于种类菜单设置等等。

The eval statement is embedded in the logic for a particular ASP.NET
Web control (telerik''s r.a.d. menu). Removing the eval() is not as
simple as you make out. Basically there is a JavaScript function in
the script library for r.a.d. menu that does an eval of what is passed
in, and that particular command - window.location.href... - might be
passed in, depending on a variety of menu settings and so forth.


Scott Mitchell写道:
Scott Mitchell wrote:
eval语句嵌入在逻辑中对于特定的ASP.NET
Web控件(telerik的rad菜单)。删除eval()并不像你想象的那么简单。基本上,r.a.d的脚本库中有一个JavaScript函数。菜单执行传入的内容,以及特定命令 - window.location.href ... - 可能会传入,具体取决于各种菜单设置等。
The eval statement is embedded in the logic for a particular ASP.NET
Web control (telerik''s r.a.d. menu). Removing the eval() is not as
simple as you make out. Basically there is a JavaScript function in
the script library for r.a.d. menu that does an eval of what is passed
in, and that particular command - window.location.href... - might be
passed in, depending on a variety of menu settings and so forth.




然后得到一个更好的菜单系统。


-

兰迪

comp.lang.javascript常见问题 - http://jibbering.com/faq & ;新闻组周刊



Then get a better menu system.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly


这篇关于IE中的onbeforeunload和eval问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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