简体   繁体   English

样式未在IE8中应用,但在Chrome和Firefox中是

[英]Styles not applied in IE8 but in Chrome and Firefox they are

I have the following html in a website. 我在网站上有以下html。 The stylings specified in "ApplicationName_ButtonDiv", "ApplicationName_Button" etc are applied correctly in Chrome and Firefox but in IE8 they aren't. 在“ ApplicationName_ButtonDiv”,“ ApplicationName_Button”等中指定的样式可在Chrome和Firefox中正确应用,但在IE8中则不能。

<div class="CommandButtonContainer">
   <div class="ApplicationName_ButtonDiv">
      <button id="changeName" type="button" class="ApplicationName_Button"onclick = "javascript: window.location='/Application/Customer/EditName';" >
         <a href="#" class="ApplicationName_Button">
            <span>
               <span>Change Name</span>
            </span>
         </a>
      </button>
   </div>
</div>

1) There is an error on the page only in IE8: 1)仅在IE8中页面上有错误:

Webpage error details 网页错误详细信息

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; chromeframe/18.0.1025.162; InfoPath.1; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E) Timestamp: Sun, 11 Aug 2013 10:06:22 UTC 用户代理:Mozilla / 4.0(兼容; MSIE 8.0; Windows NT 5.1; Trident / 4.0; chromeframe / 18.0.1025.162; InfoPath.1; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 1.1.4322 ; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)时间戳:UTC,2013年8月11日,10:06:22

Message: Permission denied Line: 5514 Char: 3 Code: 0 URI: NAME OF SITE REMOVED/publishmode.xxxjs 消息:权限被拒绝行:5514字符:3代码:0 URI:站点名称已删除/publishmode.xxxjs

This seems to relate to: 这似乎与以下方面有关:

 5513 contents: function( elem ) { 5514 return jQuery.nodeName( elem, "iframe" ) ? 5515 elem.contentDocument || elem.contentWindow.document : 5516 jQuery.makeArray( elem.childNodes ); 5517 } 

2) When you view the html in IE Developer Tools it appears slightly, but importantly, differently to when you view source: 2)当您在IE开发人员工具中查看html时,它看上去略有不同,但重要的是,与查看源代码时有所不同:

<div class="CommandButtonContainer">
   <div class="ApplicationName_ButtonDiv">
      <button class="ApplicationName_Button" id="changeName" onclick="javascript: window.location='/Application/Customer/EditName';" type="button">
         <a class="ApplicationName_Button" href="#"/>
         <span>
            <span>
           Text - Change Name
            Text - Empty Text Node (italics)
         </a/>
      Text - Empty Text Node (italics)

The anchor tag has been closed and the span tag isn't now wrapped in it. 定位标记已关闭,而span标记现在未包装在其中。 The styling relies on there being an anchor with two spans inside. 样式依赖于内部有两个跨度的锚点。 This may just be a quirk of the Tool as I have only just started using it. 这可能只是该工具的一个怪癖,因为我才刚刚开始使用它。

If you have any ideas as to what is causing this issue please let me know. 如果您对导致此问题的原因有任何想法,请告诉我。 Thanks John 谢谢约翰

Make your button into an a tag: 使您的按钮成为标签:

You have: 你有:

<button id="changeName" type="button" class="ApplicationName_Button"onclick = "javascript: window.location='/Application/Customer/EditName';" >
         <a href="#" class="ApplicationName_Button">
            <span>
               <span>Change Name</span>
            </span>
         </a>
      </button>

Try making it just: 尝试使其:

<a id="changeName" class="ApplicationName_Button" type="button" onclick="javascript: window.location='/Application/Customer/EditName';">Change Name</a>

See if that works for you...Just that section alone the way you have doesn't really make sense. 看看这是否对您有用...仅以您自己的方式来看那一部分并没有多大意义。 Also, you have a span within a span...why? 另外,您的跨度在一个跨度内...为什么?

If IE's Dev Tools shows the layout differently to how you expect it, then it's usually a sign that there are HTML errors in your code that are causing IE's parser to choke a bit. 如果IE的开发工具以与您期望的方式不同的方式显示布局,则通常表明您的代码中存在HTML错误,这些错误导致IE的解析器有点停滞。 So the first thing to do is check for that: Go to the W3C's HTML Validator and fix any errors that it reports. 因此,要做的第一件事是进行检查:转到W3C的HTML验证程序,并修复它报告的所有错误。

This could also possibly account for the missing styles; 这也可能导致缺少样式。 it's hard to be sure without seeing it in action, but if you're lucky, that'll solve that problem too. 很难确定没有实际行动,但是如果您很幸运,那也将解决该问题。 If it doesn't, then you'll need to show us the relevant CSS in order to get more help. 如果没有,那么您需要向我们展示相关的CSS以获得更多帮助。 (edit the question to include it). (编辑问题以将其包括在内)。

The CSS could well be relevant, particularly for a <button> tag, as the default styles for buttons are not completely consistent cross-browser, particularly older browsers like IE8. CSS很可能是相关的,尤其是对于<button>标记,因为按钮的默认样式不是完全一致的跨浏览器,尤其是像IE8这样的旧版浏览器。 You might want to consider using a CSS "Reset" stylesheet to normalise some of the browser differences like this. 您可能需要考虑使用CSS“重置”样式表来规范某些浏览器差异,例如这样。

You mention a Javascript permission denied error. 您提到了Javascript permission denied错误。 I don't think that's relevant to your button not being styled properly (though to be honest, it's impossible to tell given the limited amount of code you've given), but it would obviously still be a problem and would be breaking something on your site, even if it isn't that. 认为这与按钮的样式不正确有关(虽然,老实说,鉴于您提供的代码数量有限,这是不可能的),但这显然仍然是一个问题,并且会破坏某些内容您的网站,即使不是那样。

The permission problem is to with your JS code trying to access the contents of an iframe element. 权限问题是您的JS代码尝试访问iframe元素的内容。 If you're getting permission errors, then it means that the browser thinks that the page inside the iframe is from a different domain to that of your main site, and thus it won't let your code modify it for security reasons. 如果您遇到权限错误,则意味着浏览器认为iframe中的页面与主站点位于不同的域,因此出于安全原因,它不会让您的代码对其进行修改。

I don't know what this iframe is on your site, but whatever it is, it would seem that any code that works inside it is not going to work. 我不知道此iframe在您的网站上是什么,但是无论它是什么,似乎任何在其中运行的代码都行不通。

IE8's security model is fairly good in this respect, but does have some quirks. IE8的安全性模型在这方面是相当不错的,但确实有一些奇怪之处。 One in particular catches a lot of people, which is that an empty page - ie defaulting to the about:blank URL - can be considered from a different domain. 特别是一个吸引了很多人的地方,那就是可以从另一个域考虑about:blank页(即默认为about:blank URL)。 In this case, it clearly doesn't matter, but the browser isn't smart enough to know that. 在这种情况下,这显然无关紧要,但是浏览器并不足够聪明。 If that's your problem you can work around it by having the code load a dummy page from your site rather than using about:blank as the default. 如果这是您的问题,则可以通过使代码从您的网站加载虚拟页面来解决,而不必使用about:blank作为默认值。

There are other possible quirks that could be happening, but from the detail I've got from the question, that seems to be the most likely. 还有其他可能发生的怪癖,但是从我从问题中得到的细节来看,这似乎是最有可能的。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么jquery在IE8中不起作用,但在chrome / firefox中 - why jquery not working in IE8 , but in chrome/firefox jsfiddle适用于FireFox,Chrome但不适用于IE8 - jsfiddle works in FireFox, Chrome but not IE8 jQuery Ajax(beforeSend和complete)在FireFox上正常工作,但在IE8和Chrome上没有 - jQuery Ajax (beforeSend and complete) working properly on FireFox but not on IE8 and Chrome jQuery消息代码段可在Chrome / Firefox中运行,而不能在IE8中运行 - JQuery message code snippet works in Chrome / Firefox, not in IE8 jQuery:first和.first()在Chrome / Safari和FireFox / IE8中的行为不同 - jQuery :first and .first() behaving differently in Chrome/Safari and FireFox/IE8 jQuery fadeIn fadeOut在IE8中不起作用,但在chrome,firefox中起作用 - Jquery fadeIn fadeOut not working in IE8 but working in chrome, firefox jQuery代码可在Firefox中运行,但无法在Chrome和IE8中运行 - jQuery code working in Firefox but fails in Chrome and IE8 jQuery ajax可在Chrome和Safari中使用,但不能在IE8和Firefox中使用 - Jquery ajax works in Chrome and Safari, but not in IE8 and Firefox 在Firefox和Chrome中使用jQuery提取JSON结果时出现问题(IE8 Works) - Problem Fetching JSON Result with jQuery in Firefox and Chrome (IE8 Works) jQuery Datepicker仅在IE8中有效(不适用于Firefox,不适用于Chrome) - JQuery Datepicker only works in IE8 (no Firefox, no chrome for me)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM