即时添加新样式(IE,FF) [英] Add a new style on the fly (IE, FF)

查看:71
本文介绍了即时添加新样式(IE,FF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




这次我想尝试添加一个样式。我希望与

这个相同(只有menuItemStyle行) :


< head>

< style type =" text / css" media =" screen">

......一些静态样式...

..menuItemStyle {

background:#ddeeff; border-width:1px; border-style:inset; font-family:Arial; font-size:11px

}

.....

img {behavior:url(iepngfix.htc); }

< / style>


我试图从NG那里得到,但到目前为止我出来了这个:


var style = document.createElement(''style'');

style.type =''text / css'';

style。 styleSheet.addRule(''。menuItemStyle,''

background:#ddeeff; border-width:1px; border-style:inset; font-family:Arial; font-size:11px'') ;


document.getElementsByTagName(''head'')[0] .appendChild(样式)


它无效。我需要它与FF和IE一起工作。你能否请

帮助我纠正上述问题。我错了什么?


谢谢你,


Pam

Hi,

this time I am trying to add a style on the fly.I wish equivalency with
this one (only the menuItemStyle line):

<head>
<style type="text/css" media="screen">
... some static styles ...
..menuItemStyle{
background:#ddeeff;border-width:1px;border-style:inset;font-family:Arial;font-size:11px
}
.....
img { behavior: url(iepngfix.htc); }
</style>

I tried to get from the NG, but so far I came out with this one:

var style = document.createElement(''style'');
style.type = ''text/css'';
style.styleSheet.addRule(''.menuItemStyle, ''
background:#ddeeff;border-width:1px;border-style:inset;font-family:Arial;font-size:11px'');

document.getElementsByTagName(''head'')[0].appendChild(style)

and it is not working. I need it to work with FF and IE. Can you please
help me correct the above. What am I getting wrong?

Thanks you,

Pam

推荐答案




1月20日下午5:21,pamelaflue ... @ libero.it写道:


On Jan 20, 5:21 pm, pamelaflue...@libero.it wrote:




这次我正在试图添加一种风格。我希望与

相当于这个(只有menuItemStyle line):


< head>

< style type =" text / css" media =" screen">

..一些静态样式...

.menuItemStyle {

背景:#ddeeff; border- width:1px; border-style:inset; font-family:Arial; font-size:11px} ....

img {behavior:url(iepngfix.htc); }

< / style>


我试图从NG那里得到,但到目前为止我出来了这个:


var style = document.createElement(''style'');

style.type =''text / css'';

style。 styleSheet.addRule(''。menuItemStyle,''

background:#ddeeff; border-width:1px; border-style:inset; font-family:Arial; font-size:11px'') ;


document.getElementsByTagName(''head'')[0] .appendChild(样式)


它无效。我需要它与FF和IE一起工作。你能否请

帮助我纠正上述问题。我错了什么?


谢谢你,


Pam
Hi,

this time I am trying to add a style on the fly.I wish equivalency with
this one (only the menuItemStyle line):

<head>
<style type="text/css" media="screen">
.. some static styles ...
.menuItemStyle{
background:#ddeeff;border-width:1px;border-style:inset;font-family:Arial;font-size:11px}....
img { behavior: url(iepngfix.htc); }
</style>

I tried to get from the NG, but so far I came out with this one:

var style = document.createElement(''style'');
style.type = ''text/css'';
style.styleSheet.addRule(''.menuItemStyle, ''
background:#ddeeff;border-width:1px;border-style:inset;font-family:Arial;font-size:11px'');

document.getElementsByTagName(''head'')[0].appendChild(style)

and it is not working. I need it to work with FF and IE. Can you please
help me correct the above. What am I getting wrong?

Thanks you,

Pam



你收到任何你知道的错误吗?在Firefox中使用JavaScript

控制台可能会有很大帮助,因为它可以让你知道JavaScript和CSS中的
错误。此外,我相信Firefox使用

insertRule而不是Internet Explorer使用的addRule。


希望这会有所帮助。


Daz。

Are you getting any errors that you know of? Using the JavaScript
console in Firefox would probably help a lot as it lets you know of
errors in both JavaScript and CSS. Also, I believe that Firefox uses
insertRule as opposed to addRule, which Internet Explorer uses.

Hope this helps.

Daz.



>

你得到了吗?你知道的任何错误?在Firefox中使用JavaScript

控制台可能会有很大帮助,因为它可以让你知道JavaScript和CSS中的
错误。此外,我相信Firefox使用

insertRule而不是Internet Explorer使用的addRule。


希望这会有所帮助。
>
Are you getting any errors that you know of? Using the JavaScript
console in Firefox would probably help a lot as it lets you know of
errors in both JavaScript and CSS. Also, I believe that Firefox uses
insertRule as opposed to addRule, which Internet Explorer uses.

Hope this helps.



感谢Daz我会尝试。


另一个问题是我不知道怎么调试
FIrefox中的
javascript,我的IDE(Visual Studio)是

那里有任何一步一步的解释吗?

Thanks Daz I will try that.

Another problem is that I do not know how to debug
javascript in FIrefox, with my IDE (Visual Studio) is
there any step by step explanation somewhere?


>

达兹。
>
Daz.



pa * **********@libero.it 写道:

pa***********@libero.it wrote:


你是得到你知道的任何错误?在Firefox中使用JavaScript

控制台可能会有很大帮助,因为它可以让你知道JavaScript和CSS中的
错误。此外,我相信Firefox使用

insertRule而不是Internet Explorer使用的addRule。


希望这会有所帮助。

Are you getting any errors that you know of? Using the JavaScript
console in Firefox would probably help a lot as it lets you know of
errors in both JavaScript and CSS. Also, I believe that Firefox uses
insertRule as opposed to addRule, which Internet Explorer uses.

Hope this helps.



谢谢Daz我会试试。


另一个问题是我不知道怎么调试
FIrefox中的
javascript,我的IDE(Visual Studio)是

那里有任何一步一步的解释吗?


Thanks Daz I will try that.

Another problem is that I do not know how to debug
javascript in FIrefox, with my IDE (Visual Studio) is
there any step by step explanation somewhere?



我是不确定。就个人而言,我很少发现需要进行调试。我只需要使用控制台,并修复出现的错误/警告,并且当它们出现时,它们将是b $ b。另外,我使用jslint.com检查我的代码是否显而易见

错误。


如果安装Firefox,然后安装Firebug插件(来自
https://addons.mozilla.org/firefox/1843/),你可以只做

关于你需要做的所有JavaScript调试,包括

(但不限于)添加断点,单步执行代码和

检查DOM。


另一个我发现非常方便的扩展,是Web Developer

扩展,可以从
下载 https://addons.mozilla.org /火狐/ 60 / 。起初有点难以使用

,但是一旦你意识到它有多么强大,那么你之间就无法做到这么多。这两个扩展。另外,我还没有看到任何类似于IE的东西。


就个人而言,我不知道如何在没有工具的情况下管理,所以我将b $ b推荐给每个人,因为它确保生活更轻松。


希望这会有所帮助。


Daz。

I am not sure. Personally, I rarely find the need to debug as such. I
just use the console, and fix the errors/warnings that come up, as and
when they come up. Also, I use jslint.com to check my code for obvious
mistakes.

If you install Firefox, and then install the Firebug addon (from
https://addons.mozilla.org/firefox/1843/), you will be able to do just
about all the JavaScript debugging you will ever need to do, including
(but not limited to) adding break points, stepping through the code and
inspecting the DOM.

Another extension that I find extremely handy, is the Web Developer
extension, which can be download from
https://addons.mozilla.org/firefox/60/. It''s a little hard to get used
to at first, but once you realise just how powerful it is, there''s not
really much you cannot do between the two extensions. Also, I have
never seen anything quite like this for IE.

Personally, I don''t know how I ever managed without the tools, so I
recommend them to everyone as it makes life a lot easier, for sure.

Hope this helps.

Daz.


这篇关于即时添加新样式(IE,FF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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