需要在常规超链接后面执行代码
我有一个奇怪的情况。我有一个网站,其中超链接是动态生成的(作为用户控件),其 target
属性设置为 _blank
因为我需要它在新窗口中打开。由于新页面显示内容的性质,我需要在用户单击它时进行审核。我已经设置了审核功能,因此我正在寻找一种在链接打开新页面之前运行代码的方法。
如果它位于同一站点的内部页面中,我可以简单地将超链接作为命令按钮,运行审核代码,然后执行 Response.Redirect() 。
我对目标页面没有任何控制权,因为它们位于不同的网站上。我对她感兴趣,其他人是如何做到这一点的,以及是否可以按照我解释的方式做到这一点!
I have a strange situation. I have a website where hyperlinks are dynamically generated (as user controls) which have the target
attribute set to _blank
as I need it to open in a new window. Due to the nature of what the new page is displaying I need to audit when the user clicks on it. I already have auditing functionality set up so I am looking for a way to run code before the link opens the new page.
If it was in internal page on the same site i could simply have the hyperlink as a command button which runs the audit code and then does a Response.Redirect()
.
I don't have any control over the target pages because they are on a different website. I would be interested to her how others have done this and whether it's possible to do it in the way that I've explained!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将您的链接更改为网站上的处理程序,执行审核然后重定向。因此,您的链接将类似于
您的处理程序审核,读取
targetUrl
参数,然后重定向。Change your links to be a handler on your site that does the auditing and then redirects. So your links would be something like
Your handler audits, reads the
targetUrl
parameter and then redirects.您仍然可以使用 Response.Redirect() 技术,还是我在这里遗漏了一些东西?将真正的超链接作为参数传递到您的审核页面...
You can still do the
Response.Redirect()
technique, or am I missing something here? Have the real hyperlinks passed as parameters to your audit page...由于您想在新窗口(选项卡)中打开链接
我建议使用 JavaScript Window.Open 并在此之前使用 AJAX 调用进行审核。这必须是快速且更好的用户体验。
Since you want to open the link in a new window (tab)
I would suggest a JavaScript Window.Open and before that a AJAX call for your Audit. This will be must fast and better UX.