English 中文(简体)
Java 说,了解东道方的文字是怎样的?
原标题:In Javascript any way to know what host script was loaded from?
  • 时间:2010-08-26 19:50:20
  •  标签:
  • javascript

在javascript,作为装自一些主机的文字,是否有任何办法了解服务器/第一机的装载量? 我需要再次向东道国提出贾克斯要求,并且更愿意积极向东道国表示。

因此,如果你在一页上列入一个java书写文件。

<script src="http://somehost.com/js/test.js"></script>

当该javascript 执行时,在试验范围内......

var host_loaded_from = ??? // should be somehost.com 

增 编

最佳回答

是否有任何办法了解服务器/东道网站I的装载?

是的,如果该笔文字用<代码>defer或作为装饰,则可能,但除外,因为管理局的最后一份文字不一定是目前在该案中的执行文字。 See the comments by @kangax for more information.

另外,最近张贴了

在您的测试中,有最后的文字内容,即目前为平级文字(在您的案例中为测试js),并且有<>条码<>。

// test.js
var scripts = document.getElementsByTagName( script );
var src = scripts[scripts.length - 1].src;

src》中有一条,用regex对东道方进行分类。

src.match(new RegExp( https?://[^/]* ))
["http://somehost.com"] // for your example
问题回答

该书是否知道自己的档案名称? (单位:千美元)

如果是的话,你的文字可以质疑所有文字标签的占支配地位,看上去的是那些具有弧特性的人。 但是,你需要看看两部有相同名称的双字母,由不同的服务器装载。 iii

<script src="http://somehost.com/js/test.js"></script>
<script src="http://somehost_number2.com/js/test.js"></script>

这里的“共同财产”是指所有手套:

var scripts = el.getElementsByTagName( SCRIPT );

Nope, sorry.

如果<代码><script>有id,则可能是。 但你确实可以依赖这一点。

不清楚能否用 Java本做到这一点。 如果该书封面存放在PHP档案中,就这样:

...
var host_loaded_from = <?php echo $_SERVER[SERVER_NAME] ?>
...

在我的网站上,我仅因这一原因使用购买力平价的书面陈述。 我很想知道,是否有更好的办法。

由于萨米族原产地政策,你只能向原产地(东道+礼宾+港口)提出要求,但超文本(文件)的页数不一定与贵族装船的原产地相同。

您可使用<条码>window. 所在地。 东道名称或document. place.hostname,以查找文件的主名。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签