在不重定向的情况下ping一个url [英] Make a ping to a url without redirecting

查看:72
本文介绍了在不重定向的情况下ping一个url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个网址:


  • A用于重定向到登录页面

  • B用于跟踪目的(应该在不重定向的情况下对该URL进行ping)



以上操作应该在相同使用任何点击事件。



是否可以使用HTML或JavaScript来实现此功能。



我发现这个代码:

 < a href =http://www.omsaicreche.blogspot.comonclick =location.href = 'HTTP://www.omsaivatikanoida.blogspot.com';目标= _空白 >用
打开两个链接点击一次< / a>

但这里的onclick事件会重定向到这两个页面。

解决方案

为了追踪目的,您只能在B url上使用iframe。当用户点击你的链接时,一个新窗口将打开一个URL,但用户将保持在当前页面上。

 < a href =http://www.omsaicreche.blogspot.comonClick ='document.getElementById(跟踪).src =http://www.omsaivatikanoida.blogspot.com;'target =_ blank> 
点击一次即可打开两个链接
< / a>
< iframe id ='track'frameborder =0scrolling =nowidth =100height =100>

您可以将框架宽度和高度设置为可见或不可见。


I've two URLs:

  • A is used for redirecting to the landing page
  • B is used for tracking purpose (a ping should be made to this URL without redirecting)

The actions above should take place at same time using any click events.

Is it possible to achieve this using HTML or javascript.

I found this code:

<a href="http://www.omsaicreche.blogspot.com" onclick="location.href='http://www.omsaivatikanoida.blogspot.com';" target="_blank"> Open Two Links With
One Click</a>

but onclick event here redirects to both the pages.

解决方案

For trackin purpose only you can use iframe on B url . When user click your link a new window will open A url but user will remain on the current page.

<a href="http://www.omsaicreche.blogspot.com"   onClick='document.getElementById("track").src="http://www.omsaivatikanoida.blogspot.com";'" target="_blank">
  Open Two Links With One Click
</a>
<iframe id='track' frameborder="0" scrolling="no" width="100" height="100">

You can set frame width and height to be visible or not.

这篇关于在不重定向的情况下ping一个url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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