当iframe完成加载外部网站时启用计时器控制 [英] Enable timer control when iframe finishes loading external website

查看:87
本文介绍了当iframe完成加载外部网站时启用计时器控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用C#的asp.net中,我使用以下代码在按钮点击时将外部网站加载到iframe:

protected void GridView2_RowCommand(object sender,GridViewCommandEventArgs e)

In asp.net with C#, I am loading an external website into an iframe on button click using the following code:
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)

taskpage.Attributes["src"] = "somedynamicurlfromdatabase"; 
taskpage.Visible = true;



我希望启用Asp.net计时器控件当iframe中的网站加载完成时。

注意:按钮,iframe和计时器都在更新面板中。我正在使用Visual Web Developer 2010 Express



我尝试过:



i试图调用iframe并检查其属性但找不到任何解决方案。


I want an Asp.net timer control to be enabled when the website loading in iframe completes.
Note:the button, iframe and timer are in update panel. i am using Visual Web Developer 2010 Express

What I have tried:

i have tried to call the iframe and checked through its properties but could not find any solution.

推荐答案

以下是一些可能有用的资源。



如何使用JavaScript控制asp.net计时器

Andrew Frederick - 用JavaScript控制ASP.NET计时器控件 [ ^ ]



使用JavaScript启动/停止ASP.NET计时器控制 [ ^ ]



检查iframe在调用脚本之前是否已加载启用asp.net计时器

javascript - 如何检查是否是iframe加载还是有内容? - 堆栈溢出 [ ^ ]



检测iframe加载 - JavaScript - Tumult论坛 [ ^ ]



我用Google搜索了你。

LMGTFY - 使用javascript启用asp.net计时器 [ ^ ]



LMGTFY - 检查iframe是否已加载 [ ^ ]
Here are some resources that might help.

How to control asp.net timer using JavaScript
Andrew Frederick - Controlling the ASP.NET Timer Control with JavaScript[^]

Start /Stop ASP.NET Timer Control using JavaScript[^]

Check if iframe loaded before calling the script to enabled asp.net timer
javascript - How to check if iframe is loaded or it has a content? - Stack Overflow[^]

Detect iframe loaded - JavaScript - Tumult Forums[^]

I Googled that for you.
LMGTFY - enable asp.net timer with javascript[^]

LMGTFY - check if iframe is loaded[^]


这是一个例子。



1.将计时器包装在更新面板中

2.不要在元素级别禁用计时器

Here is an example.

1. Wrap the timer in the updatepanel
2. Don't disable the timer at element level
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Enabled="true" Interval="10"></asp:Timer>
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </ContentTemplate>
    </asp:UpdatePanel>

    <iframe id="taskpage" src="http://www.c-sharpcorner.com/blogs/start-stop-asp-net-timer-control-using-javascript1" >
        <p>Your browser does not support iframes.</p>
    </iframe>





3.在页面加载时,停止计时器

4.加载iframe后,启动计时器。您需要测试代码以检测iframe是否完全加载以实现跨浏览器兼容性



3. on page load, stop the timer
4. Once the iframe is loaded, start the timer. You need to test out the code to detect if iframe loaded completely for cross browser compatibility

<script>


(< span class =code-sdkkeyword> document )。ready( function (){
// 停止时间
var timer =
(document).ready(function () { //stop the time var timer =


这篇关于当iframe完成加载外部网站时启用计时器控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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