问题描述
大家好,
我正在尝试创建一些javascript,它将为
引用页面的用户提供,但如果我执行以下操作:
< HTML>
< HEAD>
< / HEAD>
< ; BODY>
< script>
<! -
url = document.referrer;
document.write(''< A HREF ="''+ url +''"> This Link< / A>'');
// - >
< / script>
< / BODY>
< / HTML>
这会在IE 6上显示一个下拉窗口(使用WInXP SP2),说明
活动内容被阻止然而,在我看到的另一个页面中使用相同的
document.referrer函数是可以的。什么是
错了?如果< scripttag包含
JavaScript,则行为是相同的。
此外,如果我有包含该页面的链接上面的代码在
网页上(比如C:\ Trev \refer1.htm),
然后引荐来源为C:\\ \\ ttrev",而不是实际的网页
推荐人。为什么?
TIA
Trev
Hi all,
I''m trying to create some javascript that will provide the user of the
referring page, but if I do something like the following:
<HTML>
<HEAD>
</HEAD>
<BODY>
<script>
<!--
url= document.referrer;
document.write(''<A HREF="'' + url + ''">This Link</A>'');
//-->
</script>
</BODY>
</HTML>
this brings out a drop-down window on IE 6 (using WInXP SP2) saying
"active content is blocked" etc. However, similar useage of the same
document.referrer function in another page I have seen is OK. What is
wrong? The behaviour is the same if the <scripttag contains
"JavaScript", or not.
Also, if I have a link to the page containing the code above on a
webpage (say "C:\Trev\refer1.htm"),
then the referrer is given as "C:\Trev", and not the actual webpage
referrer. Why?
TIA
Trev
推荐答案
< snip> ;
<snip>
< script type =" text / javascript">
删除过时的可能有害的评论。
<script type="text/javascript">
Drop the antiquated potentially-harmful comments.
< snip>
<snip>
这是因为你在本地进行测试。设置IE以允许PC区域中的Active
内容或使用Web标记。
It is because you are testing locally. Either set IE to allow Active
Content in the PC Zone or use the Mark Of The Web.
因为在打开
本地页面时,document.referrer在IE中无法正常工作。从服务器上测试它。
-
兰迪
机会有利于准备好的心灵
comp.lang.javascript常见问题 - &新闻组每周
Javascript最佳实践 -
Because document.referrer doesn''t work properly in IE when opening a
local page. Test it from a server.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
想想你在那里问什么。基本上你要问我可以控制我无法控制的计算机上的设置吗?
答案显然是否定的。如果人们从
网站上看到该消息,那么PC就会设置为发出安全警告。如果它们是从本地文件中查看它,那么在档案中搜索网络标记。
Think about what you are asking there. Basically you are asking "Can I
control the settings on a computer that I have no control over?" And the
answer is, obviously, no. If people are seeing that message from a
website, then the PC is set to give that security warning. If they are
seeing it from a local file, then search the archives for "Mark of the Web".
什么代码没有产生下拉菜单?
P.S.使用document.referrer并不会导致该菜单,它是页面中任何脚本元素(即使是一个空脚本块)的
。测试一下:
< script type =" text / javascript">
< / script>
在设置为通知的IE中打开它,即使没有代码,你也会从上面的块中得到警告
。
-
兰迪
机会有利于准备好的心灵
comp.lang.javascript常见问题 - &新闻组每周
Javascript最佳实践 -
Whats the code that doesn''t produce the drop-down?
P.S. It isn''t the use of document.referrer that causes that menu, it is
any script element in the page (even an empty script block). Test it:
<script type="text/javascript">
</script>
Open it in an IE that is set to notify, and you will get that warning
from the above block, even though there is no code in it.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
这篇关于Javascript - 显示引荐来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!