问题描述
所以我有iframe和我通过它上传文件,所以我的问题是我怎么能在加载中止它?我试图用jquery函数 attr()
更改src,但我没有做任何好处,我正在考虑使用 js 但它会造成我其他问题,我甚至不知道它是否会起作用。那么是否还有其他方法可以做到这一点?
So i have iframe and i'm uploading files through it, so my question is how can i stop it in the middle of the loading? I've tried to change src with jquery function attr()
but i didn't do any good, i'm thinking of removing the whole iframe with js
but it would create me other problems and i'm not even sure if it would work. So is there some other ways to do it?
我的下一个问题是,是否可以隐藏加载指示器,以免混淆页面加载的用户或
My next question would be, is it possible to hide loading indicators so it wouldn't confuse users that page is loading or something.
像你应该使用Flash或其他东西的答案将不会被接受我已经做了一切与iframe我只需要做这两件事。
Answers like you should use flash or other stuff won't be accepted i already did everything with iframe i just need to do those 2 things.
这是我的iframe代码:
Here is my iframe code:
<iframe onload="file_uploaded()" class="iframe" src="user/upload_image/" name="iframeTarget" ></iframe>
推荐答案
我相信以下答案是您的问题:
I believe the following answers your question:https://stackoverflow.com/a/2207589/1157493
window.frames[0].stop()
对于IE,您可以对文档执行相同的操作。 execCommand('Stop'):
For IE, you can do the same thing with document.execCommand('Stop'):
window.frames[0].document.execCommand('Stop')
对于您可以使用的跨浏览器解决方案:
For a cross-browser solution you could use:
if (navigator.appName == 'Microsoft Internet Explorer') {
window.frames[0].document.execCommand('Stop');
} else {
window.frames[0].stop();
}
如果您希望将iframe转到另一个页面,您可以尝试将其重定向到about:blank。
If you'd like the iframe to go to a different page you could try to redirect it to "about:blank"
这篇关于从加载停止iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!