Javascript - 显示引荐来源 [英] Javascript - display referrer

查看:80
本文介绍了Javascript - 显示引荐来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试创建一些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

推荐答案

Trev在2006年10月17日上午5:49发表以下内容:
Trev said the following on 10/17/2006 5:49 AM:

大家好,

我正在尝试创建一些javascript,将为用户提供

引用页面,但如果我执行以下操作:
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:



< snip> ;

<snip>


< script>

<! -
<script>
<!--



< script type =" text / javascript">


删除过时的可能有害的评论。

<script type="text/javascript">

Drop the antiquated potentially-harmful comments.


url = document.referrer;


document.write(''< A HREF ="''+ url +''"> This Link< / A>'') ;
url= document.referrer;

document.write(''<A HREF="'' + url + ''">This Link</A>'');



< snip>

<snip>


这会在IE 6上显示一个下拉窗口(使用WInXP SP2)说

活动内容被阻止然而,在我看到的另一个页面中使用相同的

document.referrer函数是可以的。什么是

错了?如果< scripttag包含

JavaScript,则行为相同。
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.



这是因为你在本地进行测试。设置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.


另外,如果我有链接在

网页上包含上述代码的页面(比如C:\ Trev \refer1.htm),

然后引荐来源为 ; C:\ Trev",而不是实际的网页

推荐人。为什么?
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?



因为在打开

本地页面时,document.referrer在IE中无法正常工作。从服务器上测试它。


-

兰迪

机会有利于准备好的心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /

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/


谢谢。


有没有办法阻止活动内容被阻止窗QUOT;

我无法控制的电脑?它只是我已经看到了两个引用代码的b / b
实现;一个产生下拉

windown,一个没有。

Thanks.

Is there any way to stop the "Active content blocked window" on
computers over whom I have no control? Its just that I''ve seen two
implementations of the referrer code; one produces the drop-down
windown and one doesn''t.


Trev在10/17 /上说了以下内容2006年6:47 AM:
Trev said the following on 10/17/2006 6:47 AM:

谢谢。


有没有办法停止Active content blocked window

我无法控制的电脑?
Thanks.

Is there any way to stop the "Active content blocked window" on
computers over whom I have no control?



想想你在那里问什么。基本上你要问我可以控制我无法控制的计算机上的设置吗?

答案显然是否定的。如果人们从

网站上看到该消息,那么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".


它只是我已经看到两个引用代码的实现;

一个产生下拉窗口而一个不产生。
Its just that I''ve seen two implementations of the referrer code;
one produces the drop-down windown and one doesn''t.



什么代码没有产生下拉菜单?

P.S.使用document.referrer并不会导致该菜单,它是页面中任何脚本元素(即使是一个空脚本块)的

。测试一下:


< script type =" text / javascript">

< / script>


在设置为通知的IE中打开它,即使没有代码,你也会从上面的块中得到警告




-

兰迪

机会有利于准备好的心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq &新闻组每周

Javascript最佳实践 - http://www.JavascriptToolbox .com / bestpractices /

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 - 显示引荐来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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