admin管理员组文章数量:1287151
Is there any way to configure IIS or Web app to automatically open a new window when a hyperlink is clicked? My issue isn't as trivial as it sounds, let me explain... I understand you can use JavaScript or target="_blank"
in the anchor tag, but I don't always know when an anchor tag might be listed on the page...
The reason is that it's a user forum, think of stack overflow ;) where a user might enter a URL (allowed) and it's not necessarily known, or it was entered aeons ago and there is no way to tell.
I'm pretty sure the answer is no and I'll just have to analyze for URLs when the post/entry is being saved and convert it to do this then.
Is there any way to configure IIS or Web app to automatically open a new window when a hyperlink is clicked? My issue isn't as trivial as it sounds, let me explain... I understand you can use JavaScript or target="_blank"
in the anchor tag, but I don't always know when an anchor tag might be listed on the page...
The reason is that it's a user forum, think of stack overflow ;) where a user might enter a URL (allowed) and it's not necessarily known, or it was entered aeons ago and there is no way to tell.
I'm pretty sure the answer is no and I'll just have to analyze for URLs when the post/entry is being saved and convert it to do this then.
Share Improve this question edited Oct 13, 2020 at 20:43 10 Rep 2,2707 gold badges21 silver badges33 bronze badges asked May 1, 2009 at 22:17 bbqchickenrobotbbqchickenrobot 3,7094 gold badges48 silver badges70 bronze badges 1- Or I suppose I could analyze HTML content being written to the page for a URL and then add the appropriate code... hmmm... there has to be someone who has tried this already and discovered some nifty pattern to solve this. – bbqchickenrobot Commented May 1, 2009 at 22:23
3 Answers
Reset to default 10<html>
<head>
<base target='_blank'> <!-- Here's the interesting bit -->
</head>
<body>
<p><a href='http://google.'>New window!</a></p>
</body>
</html>
Of course that really will do all links - if you want a link to be an exception to the rule, and to open in the current window, do this:
<p><a href='http://google.' target='_self'>Not new window!</a></p>
IIS wouldn't have anything to do with it - short of writing a filter that would rewrite all your links. I'd suggest JQuery, where it should be as easy as:
$(function() {
$('A').attr('target', '_blank');
});
You could create an HTTP Module which catches the ReleaseRequestState event. Then you would attach a filter to your HttpResponse. The filter could search for <a>
tags and add the target='_blank'
to those which don't already have them.
本文标签: aspnetOpen New Window from aspx page from *any* URLStack Overflow
版权声明:本文标题:asp.net - Open New Window from aspx page from *any* URL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741273569a2369599.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论