iframe 覆盖父页面_是否可以覆盖来自父级的iFrame中的javascript?如果是这样的话?...

I'm using the Telerik RadSpell control in one of our touchscreen applications. I've managed to style it just right however the darn thing uses window.alert and window.confirm for prompting the user if they want to keep changes etc.

I want to disable these alerts without having to pull apart and modify the telerik controls.

The issue is that the spellcheck dialog uses an iframe and I can't seem to override the window.confirm function inside the iframe.

Sample Code to test overriding confirm.

window.confirm = function(msg){ alert(msg); }

confirm("Main Page Confirm");

confirm("iframe confirm");

Some content.

Results in

Is it possible to override the javascript in an iframe from the parent? If so how?

解决方案

I just shared an easier solution in the first forum, which demonstrates how to override the cancelHandler and hide the confirm dialog.

For your convenience I am pasting the solution below:

I would propose an easier way to disable the popup and it is to override the cancelHandler function. To do that follow the steps below:

1) Create a JS file named dialog.js in the root of the web application and populate it with the following function:

Telerik.Web.UI.Spell.SpellDialog.prototype.cancelHandler = function (e) {

if (this._cancel.disabled) {

return $telerik.cancelRawEvent(e);

}

//changes will be applied only if spell handler response is received, text has changed

//and the user confirms

this.closeDialog(this._spellProcessor && this._spellProcessor.textChanged() && true);

return $telerik.cancelRawEvent(e);

}

2) Save the file and set the DialogsScriptFile property of RadSpell to point to this file, e.g.

3) Test the solution.

I hope this helps.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值