HTML5 JavaScript无法在框架集中使用 [英] HTML5 javascript not working in frameset

查看:274
本文介绍了HTML5 JavaScript无法在框架集中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页托管在其他人的框架集中,但是它都在同一个域中(我的内容通过服务上传到他们的服务器上)。为什么他们使用框架集却是另一天的争论。他们不会更改其标记,因此我必须找到一种可以在我的代码中工作的解决方法。我在测试用例中发现了一个奇怪的问题,如果我能解决的话可能会有所帮助。

I have a page which is hosted in someone elses frameset, however it's all on the same domain ( my content is uploaded to their server via a service). WHY they are using a frameset is an argument for another day, however. They will not change their markup, so I have to find a workaround that can work in my code. I've found a bizarre problem in my test case that might help me if I can solve it. This is only a problem in IE as usual.

包装框架看起来像这样(用未引用的属性完成,是的):

The wrapper frame looks like this (complete with unquoted attributes, yes):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<HTML>
<HEAD>
    <TITLE>foo</TITLE>
    <META content="text/html; charset=UTF-8" http-equiv=Content-Type>
    <META content=IE=EmulateIE8 http-equiv=X-UA-Compatible>
</HEAD>
<FRAMESET frameSpacing=0 cols=8,*,8 frameBorder=1>
    <FRAME id=blackleft src="black.htm" name=blackleft scrolling=no>
    <FRAME id=content marginHeight=0 src="button.html" name=ScormContent marginWidth=0>
    <FRAME id=blackright src="black.htm" name=blackright scrolling=no>
</FRAMESET>
</HTML>

我的测试用例页面(button.html)看起来像这样:

my test case page (button.html) looks like this:

<!DOCTYPE html>
<html><head>
<meta http-equiv=X-UA-Compatible content="IE=Edge">
<title>test</title>
</head>

<body>
<section>
    <a href="javascript:alert('hello world');">
        <button>pressing me works unless you are in a frameset</button>
    </a>
</section>
<section>
    <a href="#" onclick="alert('hello world');">
        <button>Pressing me always works</button>
    </a>
</section>
</body>
</html>

我想知道为什么在框架集内使用IE9时第一个按钮没有响应-独立运行页面会导致可点击的按钮。

I'm wondering why the first button is non responsive in IE9 when it is used within a frameset - running the page standalone results in a clickable button.

关于doctype和与x-ua兼容的技巧的大量阅读使我比以往更加困惑,我可以算不出我应该做的事。如前所述,我无法以任何方式更改框架集的标记,因此为了使我的代码正常工作(它依赖于诸如beforeunload和unload事件之类的内容,以便在页面进行通信时保存数据已导航-在框架集中运行时不起作用)。我的直觉告诉我,按钮示例表明我已经解决了潜在的问题,而互联网告诉我,这与x-ua兼容的标记和怪癖模式有关,但是有关该主题的大量阅读并没有使我感到困惑一个解决方案呢...例如如果我选择强制IE9(例如)为IE7兼容模式,那么我所有的页面样式设计都将退出窗口。

Much reading about both doctypes and the x-ua-compatible trick has left me more confused than ever, and I can't work out what I'm supposed to do. As mentioned, I can not change the frameset's markup in any way, so in order for my code to work (which relies on things like the beforeunload and unload events in order to communicate data to save when the page is navigated - which don't work when running in the frameset). My gut tells me that the button example shows I'm close to the underlying problem, and the internet tells me that it's got to do with the x-ua-compatible tag and quirks mode, but much reading on the subject has not netted me a solution yet... e.g. if I choose to force IE9 to (say) IE7 compatibility mode then all my pages styling work goes out the window.

推荐答案

IE具有唯一的 iframe安全性


SECURITY属性限制了JavaScript,vbscript以及URL中协议的使用。例如,在受限帧或iframe中,源文件无法执行以下代码:

The SECURITY attribute restricts use of the javascript, vbscript, and about protocols in the URL. For example, in a restricted frame or iframe, the source file cannot execute the following code:



<a href="javascript:alert('Disallowed in restricted FRAME or IFRAME!');">JavaScript Link</a>

这篇关于HTML5 JavaScript无法在框架集中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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