IE阻止活动内容 [英] IE blocking active content

查看:112
本文介绍了IE阻止活动内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的jacascript随机化我的网页顶部

帧的背景 http://www.duke.edu/~efn 。出于某种原因,我的

Internet Explorer开始阻止后台显示这个

而不是: http://www.duke.edu/~efn/pic.jpg 。这个问题并没有用于发生
,而且在Firefox上也不会发生。有什么办法我可以改变顶部框架的脚本 http://www.duke.edu/~efn/top.html

防止这种情况发生?谢谢。 -Emmett

I have a simple jacascript that randomizes the background of the top
frame of my webpage http://www.duke.edu/~efn. For some reason, my
Internet Explorer started blocking the background and displaying this
instead: http://www.duke.edu/~efn/pic.jpg. This problem didn''t used to
occur, and it doesn''t happen on Firefox. Is there some way I can alter
the script of the top frame http://www.duke.edu/~efn/top.html to
prevent this from happening? Thanks. -Emmett

推荐答案

文章< c7 ********************** ***@posting.google.com> ,
em ************ @ gmail.com 启发我们...
In article <c7*************************@posting.google.com> ,
em************@gmail.com enlightened us with...
我有一个简单的jacascript随机化我的网页顶部
框架的背景 http://www.duke.edu/~efn 。出于某种原因,我的
Internet Explorer开始阻止背景并显示这个
http://www.duke.edu/~efn/pic.jpg 。这个问题并没有用于发生,而且在Firefox上也不会发生。有什么方法可以改变顶部框架的脚本 http://www.duke.edu/~efn/top.html 以防止这种情况发生?谢谢。 -Emmett
I have a simple jacascript that randomizes the background of the top
frame of my webpage http://www.duke.edu/~efn. For some reason, my
Internet Explorer started blocking the background and displaying this
instead: http://www.duke.edu/~efn/pic.jpg. This problem didn''t used to
occur, and it doesn''t happen on Firefox. Is there some way I can alter
the script of the top frame http://www.duke.edu/~efn/top.html to
prevent this from happening? Thanks. -Emmett




我看到我的系统上的IE6和Firefox 1.0没有区别。


问题出在你的IE浏览器中设置,而不是你的剧本。


-

-

~kaeli~

Kill一个男人,你是一个凶手。杀死数百万你和你b $ b是一个征服者。杀死所有人,你就是上帝。
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace



I see no difference between IE6 and Firefox 1.0 on my system.

The problem is somewhere in your IE settings, not your script.

--
--
~kaeli~
Kill one man and you are a murderer. Kill millions and you
are a conqueror. Kill everyone and you are God.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace


Emmett写道:
Emmett wrote:
我有一个简单的jacascript随机化顶部的背景
我的网页框架 http://www.duke.edu/~efn 。出于某种原因,我的
Internet Explorer开始阻止背景并显示这个
http://www.duke.edu/~efn/pic.jpg 。这个问题并没有用于发生,而且在Firefox上也不会发生。有什么方法可以改变顶部框架的脚本 http://www.duke.edu/~efn/top.html 以防止这种情况发生?谢谢。 -Emmett
I have a simple jacascript that randomizes the background of the top
frame of my webpage http://www.duke.edu/~efn. For some reason, my
Internet Explorer started blocking the background and displaying this
instead: http://www.duke.edu/~efn/pic.jpg. This problem didn''t used to
occur, and it doesn''t happen on Firefox. Is there some way I can alter
the script of the top frame http://www.duke.edu/~efn/top.html to
prevent this from happening? Thanks. -Emmett




下面是你的脚本,我对它的评论:


< script language =" javascript" >


使用:< script type =" text / javascript">


var bgNum = Math.round(Math。 random()* 6);


使用:var bgNum = Math.floor(Math.random()* 6);

< url:< a rel =nofollowhref =http://jibbering.com/faq/#FAQ4_22target =_ blank> http://jibbering.com/faq/#FAQ4_22 />


bgSel = new Array(7);

bgSel [0] =" 1.jpg" ;;

bgSel [1] = " 2.jpg";

bgSel [2] =" 3.jpg";

bgSel [3] =" 4.jpg" ;;

bgSel [4] =" 5.jpg";

bgSel [5] =" 6.jpg" ;;

bgSel [6] = " 7.jpg";


使用:

var bgSel = [

" 1.jpg",

" 2.jpg",

" 3.jpg",

" 4.jpg",

5。 jpg",

" 6.jpg",

" 7.jpg"

];


var base = bgSel [bgNum];


注意:你真的不需要将它分配给另一个变量。


< / script>


< / head>


< script language =" javascript">

document.write("< body background =''" + base +"''>");

< / script>

注意:这里你的标记无效,因为你有一个< script>标签

在< head>< / head>之外和< body>< / body>。如果Javascript被禁用,

该页面没有< body>标签。


相反,你应该使用:


< head>

< style type =" text / css">

body {background-image:url(default.jpg); }

< / style>

< script type =" text / javascript">

var bg = [

" 1.jpg"," 2.jpg"," 3.jpg"," 4.jpg",

" 5.jpg"," 6.jpg"," 7.jpg"

];

document.write(

''< style type =" text / css">'',

''body {background-image:url('',

bg [Math.floor(Math.random()* bg.length)],

'');}'',

''< \ / style>''

) ;

< / script>

< / head>

< body>


现在你可以通过简单地添加更多元素来扩展图像数量(因为我们使用的是bg.length而不是固定数字)。


如果用户已禁用CSS或过度使用CSS,则他们没有(或他们选择

)背景图像。


如果他们已启用CSS但JavaScript d他们得到了默认的

背景图片(指定为default.jpg)。


如果他们启用了CSS并启用了JavaScript,他们会随机选择

of 1..7.jpg。


在任何情况下,他们都不会得到无效的标记或没有< body>的页面标签。

在IE 6.0.2800,Firefox 1.0PR,Netscape 4.78,Opera

6.05,Opera 7.54和Mozilla 1.7.3中测试和工作。
< br $>
-

Grant Wagner< gw ***** @ agricoreunited.com>

comp.lang.javascript常见问题 - http://jibbering.com/faq



Below is your script, and my comments on it:

<script language="javascript">

Use: <script type="text/javascript">

var bgNum = Math.round(Math.random() * 6);

Use: var bgNum = Math.floor(Math.random() * 6);
<url: http://jibbering.com/faq/#FAQ4_22 />

bgSel = new Array(7);
bgSel[0] = "1.jpg";
bgSel[1] = "2.jpg";
bgSel[2] = "3.jpg";
bgSel[3] = "4.jpg";
bgSel[4] = "5.jpg";
bgSel[5] = "6.jpg";
bgSel[6] = "7.jpg";

Use:
var bgSel = [
"1.jpg",
"2.jpg",
"3.jpg",
"4.jpg",
"5.jpg",
"6.jpg",
"7.jpg"
];

var base = bgSel[bgNum];

Note: You don''t really need to assign this to another variable.

</script>

</head>

<script language="javascript">
document.write("<body background=''" + base + "''>");
</script>

Note: you''ve got invalid markup here, because you''ve got a <script> tag
outside of <head></head> and <body></body>. And if Javascript is disabled,
the page gets no <body> tag at all.

Instead, you should use:

<head>
<style type="text/css">
body { background-image: url(default.jpg); }
</style>
<script type="text/javascript">
var bg = [
"1.jpg", "2.jpg", "3.jpg", "4.jpg",
"5.jpg", "6.jpg", "7.jpg"
];
document.write(
''<style type="text/css">'',
''body { background-image: url('',
bg[Math.floor(Math.random() * bg.length)],
''); }'',
''<\/style>''
);
</script>
</head>
<body>

Now you can expand the number of images by simply adding more elements to
the array (because we''re using bg.length instead of a fixed number).

If the user has CSS disabled or over-ridden, they get no (or their choice
of) background-image.

If they have CSS enabled but JavaScript disabled they get the default
background-image (specified as default.jpg).

If they have CSS enabled and JavaScript enabled they get a random choice
of 1..7.jpg.

In no case do they get invalid markup or a page with no <body> tag.
Tested and working in IE 6.0.2800, Firefox 1.0PR, Netscape 4.78, Opera
6.05, Opera 7.54 and Mozilla 1.7.3.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq


Emmett写道:
Emmett wrote:
我有一个简单的jacascript随机化我的网页顶部
框架的背景 http://www.duke.edu/~efn 。出于某种原因,我的
Internet Explorer开始阻止背景并显示这个
http://www.duke.edu/~efn/pic.jpg 。这个问题并没有用于发生,而且在Firefox上也不会发生。有什么方法可以改变顶部框架的脚本 http://www.duke.edu/~efn/top.html 以防止这种情况发生?谢谢。 -Emmett
I have a simple jacascript that randomizes the background of the top
frame of my webpage http://www.duke.edu/~efn. For some reason, my
Internet Explorer started blocking the background and displaying this
instead: http://www.duke.edu/~efn/pic.jpg. This problem didn''t used to
occur, and it doesn''t happen on Firefox. Is there some way I can alter
the script of the top frame http://www.duke.edu/~efn/top.html to
prevent this from happening? Thanks. -Emmett




哦,是的,Internet Explorer 6.0.2900(Windows XP Service Pack 2)将

阻止document.write()如果你在本地加载网站就会发生。

但是从Web服务器加载它应该可以正常工作。


-

Grant Wagner< gw ***** @ agricoreunited.com>

comp.lang.javascript常见问题 - http://jibbering.com/faq



And oh yes, Internet Explorer 6.0.2900 (Windows XP Service Pack 2) will
prevent the document.write() from occurring if you load the site locally.
But loaded off a Web server it should work okay.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq


这篇关于IE阻止活动内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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